How to change the 'laravel_session' and 'XSRF-TOKEN' Expires/Max-age value to 'Session' instead of a timespan ?
Dear Friends,
I am using Laravel 10.10 . As part of my application security audit the team compel to change the value of Expires/Max-age value of 'laravel_session' & 'XSRF-TOKEN' to "Session".
Please see the screenshot
@s4muel As per expert opinion "'expire_on_close' => true: When you set this option to true, the session cookie will have no specific expiration time set, and it will be deleted when the user closes their browser (i.e., when the browser session ends). The Expires and Max-Age attributes of the cookie will not be set, effectively making it a session cookie."
In my case too it's not working , I already set it..
@insight exactly as you say "...effectively making it a session cookie", that is what it is, the value "Session" you see is just fictional, not a real value, to indicate it it a session cookie
to understand why you do not set the cookie value to 'Session'
Your browser shows the label 'Session' to indicate that the expiry is not set. It is the absence of the expiry parameter that makes it last only until the browser is closed
@insight do i see correctly, that you set 'expire_on_close' => true in config/session.php as your solution (as in the url you posted) or am i missing something?
did you try setting it (just the expire_on_close) on fresh laravel project? try it and see for yourself that it just works as you want. and find out why it doesnt work on your current project. instead of messing up with custom session and csrf middlewares that can bite you in the future.
and what is the purpose of this? 'lifetime' => env('SESSION_LIFETIME', 'Session') do you even use it anywhere?
🤯