Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to store a value in the session.
Laravel
<?php use Illuminate\Support\Facades\Session; Session::[1]('key', 'value');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'put' to store data.
Using 'forget' which deletes data.
✗ Incorrect
Use put to store a value in the session.
2fill in blank
mediumComplete the code to retrieve a value from the session.
Laravel
<?php use Illuminate\Support\Facades\Session; $value = Session::[1]('key');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' which stores data instead of retrieving.
Using 'forget' which removes data.
✗ Incorrect
Use get to retrieve a value from the session.
3fill in blank
hardFix the error in the code to remove a session value.
Laravel
<?php use Illuminate\Support\Facades\Session; Session::[1]('key');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which only reads data.
Using 'put' which writes data.
✗ Incorrect
Use forget to remove a value from the session.
4fill in blank
hardFill both blanks to check if a session key exists and then retrieve it.
Laravel
<?php use Illuminate\Support\Facades\Session; if (Session::[1]('key')) { $value = Session::[2]('key'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' instead of 'get' to retrieve data.
Using 'forget' which deletes data.
✗ Incorrect
Use has to check if the key exists, then get to retrieve it.
5fill in blank
hardFill all three blanks to flash a message to the session and then retrieve it.
Laravel
<?php use Illuminate\Support\Facades\Session; Session::[1]('status', 'Profile updated!'); $message = Session::[2]('status'); Session::[3]('status');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' instead of 'flash' for temporary messages.
Not removing the message after retrieving.
✗ Incorrect
Use flash to store a temporary message, get to retrieve it, and forget to remove it.