How to Deleting Session Data in Laravel ?



How to Deleting Session Data in Laravel ?..

Answer / 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

More Laravel PHP Framework Interview Questions

How to get last inserted id using laravel query?

0 Answers  


How to check if value is sent in request?

0 Answers  


What are Global Middleware and Route Middleware ?

0 Answers  


How do I seed my database for column that is a foreign key referencing to other table?

0 Answers  


What is database migration in laravel? How to use this?

0 Answers  






what is meant by Listeners ?

1 Answers  


What is namespace in php laravel?

0 Answers  


Define lumen.

0 Answers  


What are the advantages of using laravel?

0 Answers  


Please explain what is laravel?

0 Answers  


How long have you been using laravel?

0 Answers  


What do you understand by lumen?

0 Answers  


Categories