How to Deleting Session Data in Laravel ?

Answer Posted / amit khanna

The forget() method is used to delete an item from the session.
This method will take key as the argument.

Syntax : $request->session()->forget('key');

Use flush() method instead of forget() method to delete all session data.
Use the pull() method to retrieve data from session and delete it afterwards.
The pull() method will also take key as the argument.
The difference between the forget() and the pull() method is that forget() method will not return the value of the session and pull() method will return it and delete that value from session.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is laravel api rate limit?

524


How to turn off crsf protection for specific route in laravel?

497


How to work with an Error in Laravel ?

1019


What is meant by Implicit Controllers

1045


What is php artisan.

517






Why we use csrf token in laravel?

490


When laravel was launched?

563


I just installed laravel and have the evil whoops error,how do I find out what’s wrong and fix it?

520


What is csrf_field () in laravel?

506


What is an observer?

546


What is the default session timeout duration?

543


What is x-csrf-token , how it is different from csrf tokens?

524


How do I set up the eloquent relationships between the aforementioned comments and authors, including creating the schema design?

500


Is laravel better than wordpress?

544


what is meant by CSRF Protection in Laravel ?

1201