Deep Gagan Guru Deep Gagan Guru - 15 days ago 8
MySQL Question

how to create session id in laravel 5.3?

how can we create session_id in laravel 5.3 and store it into mysql database?
In PHP we use :

session_id();


for generating session_id.

but how can we create session_id in laravel 5.3?
Thanks

Answer

Depends on the version of Laravel: Laravel 3:

$session_id = $_COOKIE["laravel_session"];

Laravel 4.0:

Just not versions 4.1 and above:

$session_id = session_id();

Laravel 4.1 (and onwards):

$session_id = Session::getId();

or

$session_id = session()->getId();

Answer in detail