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(); //thanks Phill Sparks
Laravel 4.1 (and onwards):
$session_id = Session::getId();
or
$session_id = session()->getId()
Laravel no longer uses the built-in PHP sessions directly, as a developer could choose to use various drivers to manage the sessions of visitors (docs for Laravel 4.2, Laravel 5.1, Laravel 5.2).
Because of this, now we must use Laravel's Session
facade or session()
helper to get the ID of the session:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…