ads

laravel session



laravel session



Hello, Here I am talking about Laravel - Session. Session driver configuration will store the session data into each and every request of the laravel. Using sessions we can get temporary data on the browser and using it until cache not clear on the browser.

Here is am using some sessions example so you can understand the Laravel - Session

1)How to put session data?

$value = $request->session()->put('data',$data);
OR
$value = Session::put('data',$data);

Here 'data' is the argument of the sessions where you can give value by put() method.


2)How to get the session data which is stored by get() method?

$value = $request->session()->get('data');
OR
$value = Session::put('data');

3)How to get the session data which is stored by destroy() method?

$value = $request->session()->forget('data');
OR
$value = Session::forget('data');

That's It.
Happy Coding.
I hope this post will help a lot.

Post a Comment

Previous Post Next Post