Put value in session variable:
Put value session variable: using laravel 5 store session value in a session variable use Session::put() method in your laravel project or web application.
A session variable store some information or some value of user details that can’t remove until user destroy it and get user details or display message using session variable.
This tutorial I will show you, how to store session value in a session variable, which variable name you define in your web page. If you want to set a value in a session variable so you need to use Session under namespace in your project or website. That’s like:
<?php namespace App; use Session; ?>
Now put the value in a session variable. That’s like put user ID in the session variable. Follow the example:
Store value in Session Variable:
<?php Session::put('user_id',$user_id); ?>
If you want to store value form the MySQL table and redirect to other page, when your work is done then you can apply this code:
For Example:
<?php if($data){ $user_id=$data[0]->user_id; Session::put('user_id',$user_id); return redirect('home'); } ?>