How to Accessing Session Data in Laravel ?

Answer Posted / amit khanna

To access the session data, we need an instance of session which can be accessed via HTTP request.
After getting the instance, we can use the get() method, which will take one argument, key, to get the session data.

Syntax : $value = $request->session()->get('key');

You can use all() method to get all session data instead of get() method.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I register a service provider?

486


Explain closures in laravel?

513


How to install laravel by composer?

563


What are enhancement features in laravel 5.8?

478


What are the three types of authentication?

486


Explain the difference between laravel and codeigniter?

518


Where is route in laravel?

528


How do I log an error?

529


What is a recursive helper function?

545


How to check ajax request in laravel?

510


what is meant by Laravel - Contracts ?

1574


What is slug in laravel?

544


What is a Laravel - Contracts ?

991


How to enable maintaince mode in laravel?

521


How can we turn off csrf protection for a particular route?

504