Level 10
That's what a session is, information per session. You can store it in a file or the database or use environmental variables on the server.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
How can I set a global session in Laravel. In a normal PHP-script a global session like $_SESSION['myvar'] dies if the browser is closed or the function session_destroy() / unset() is called.
I tried this in Laravel, but it does not work in a controller extends BaseController:
Session::set( 'id', $user->id );
Session::get( 'id' );
Please or to participate in this conversation.