Im trying to work with Sessions in Laravel 5 Middleware, but they are not working.
To be specific - var_dump(Session::all());
at the start of handle method gives me array with one value - _tokken, then at the end of this method
Session::put('lang',$locale);
var_dump(Session::all());
Gives me array with two values, _tokken and my lang key, but after refresh its the same, as I understand there should be same result after second refresh.
I though maybe I have my middleware loaded before Session middleware, which was true, then I switched and now my Kernel.php looks like this -
protected $middleware = [
'IlluminateFoundationHttpMiddlewareCheckForMaintenanceMode',
'IlluminateCookieMiddlewareEncryptCookies',
'IlluminateCookieMiddlewareAddQueuedCookiesToResponse',
'IlluminateSessionMiddlewareStartSession',
'IlluminateViewMiddlewareShareErrorsFromSession',
'AppHttpMiddlewareVerifyCsrfToken',
'AppHttpMiddlewareLanguage',
];
So I ask - what am I doing wrong?
Edit: Digging in IlluminateSessionMiddlewareStartSession I found this -
//Note that the Laravel sessions do not make use of PHP "native" sessions in any way since they are crappy.
as a comment, so my testing with session_status() is not relavent.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…