Home > Software engineering >  How to set the session id in laravel
How to set the session id in laravel

Time:10-18

I have a laravel 8 project I want to set the ID to a custom name I require. In php session_id() allows. How can I achieve that in laravel 8.

CodePudding user response:

you can use laravel global session helper

session('key', 'value');

or

by using request instance

$request->session()->put('key', 'value');

CodePudding user response:

$session_id = Session::$instance->session['id'];

or

$session_id = $_COOKIE["laravel_session"];

or

$session_id = session_id();

  • Related