Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.2 every request will be to generate a new session file

I've configured config/session.php

return [
    'driver' => 'file',
    'lifetime' => 120,
    'expire_on_close' => false,
    'encrypt' => false,
    'files' => storage_path('framework/sessions'),
    'connection' => null,
    'table' => 'sessions',
    'lottery' => [2, 100],
    'cookie' => 'laravel_session',
    'path' => '/',
    'domain' => null,
    'secure' => false,
];

I put route rule in the group web

Route::group(['middleware' => ['web']], function () {
     Route::get('/example/demo', 'ExampleController@demo');
});

The folder of storage can be written but every request will be to generate a new session file

How did this happen?

How can I solve this problem?

like image 532
lilin Avatar asked Feb 19 '16 01:02

lilin


People also ask

How can get all session in laravel?

If you just want to see contents of session, try dd() : dd(session()->all()); If not, just use this to get all info: $data = session()->all();

What is session regenerate laravel?

Laravel utilize basically the original session file store but acts a little bit different. Beside changing the directory they are saved, when you call the regenerate function it creates another session file and deletes the old one. You can see it the implementation Illuminate\Session\Store. php .

Which one is correct to set a session data in laravel?

The correct syntax for this is: Session::set('variableName', $value); For Laravel 5.4 and later, the correct method to use is put : Session::put('variableName', $value);


1 Answers

Problem is in this line :

'cookie' => 'laravel_session'

I don't know what causes the problem, laravel or browser but you can not use _ or . in cookie name.Removing underscore from cookie name will solve the problem.

And also i found this for IE : http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx

like image 154
Mr. Engineer Avatar answered Oct 13 '22 11:10

Mr. Engineer