When I move my Laravel 5.2 Project from one PC to another, sessions stop working.
I have completely the same PHP installation and php.ini (the version doesn’t matter, I’ve checked it). And I run php artisan serve
to serve my pages.
It’s obvious that the problem lays in the environment. But where exactly? The only noticeable difference is Windows’s version. I have the problem on Windows 10, and everything is ok on the Windows 7. Everything should work on both.
The bellow is a piece of code for reproducing the error. The route returns ‘value’ on every request. But it should be ‘another value’ since the second one. And it makes me mad.
//Route::group(['middleware' => ['web']], function () {
Route::get('/try', function (Request $request) {
if ($request->session()->has('key')) {
$request->session()->put('key', 'another value');
} else {
$request->session()->put('key', 'value');
}
return $request->session()->all();
});
//});
I have a fresh installed Laravel 5.2 (5.2.29) with default parameters. I’ve checked all the parameters, and, as to me, they are fine:
config\session.php
'lifetime' => 120,
'expire_on_close' => false,
.env
SESSION_DRIVER=file
php.ini
session.gc_maxlifetime = 1440
session.cookie_lifetime = 0
Sessions are being written in \storage\framework\sessions
alright, however for each request.