Support the ongoing development of Laravel.io →
Authentication Security Session
Last updated 2 years ago.
0

Session is being cleared after refreshing Site2. I'm using this code to see what my session has: $data = Session::all(); var_dump($data);

After i do login on Site 1 I have this result: array(4) { ["_token"]=> string(40) "ppzo1geWMn7559267MdKNixgRarnSi2KbhsKjp4i" ["Menu"]=> int(1) ["flash"]=> array(2) { ["old"]=> array(0) { } ["new"]=> array(0) { } } ["login_82e5d2c56bdd0811318f0cf078b78bfc"]=> string(1) "1" }

After I refresh Site2 and come back to Site1 and refresh it I have: array(2) { ["_token"]=> string(40) "ULykKJJhwpI3nSDXBEphJHMsQWMkwQVdmEdyUpQK" ["Menu"]=> int(1) }

Exacly the same I had before authentication

Last updated 2 years ago.
0

everytime i refresh Site2, for Site1 session _token and sessionID (Session::getId();) change. Is this suppose to happen?

Last updated 2 years ago.
0

Could you try to prefix your sessions like:

Session::put('s1_key', 'value');  //site1
Session::put('s2_key', 'value');  //site2

This may not solve it, but might help narrow it down some. Another framework I used had a global assignment
to prefix sessions, not sure about laravel.

Last updated 2 years ago.
0

jimgwhit said:

Could you try to prefix your sessions like:

Session::put('s1_key', 'value');  //site1
Session::put('s2_key', 'value');  //site2

This may not solve it, but might help narrow it down some. Another framework I used had a global assignment
to prefix sessions, not sure about laravel.

That's how I use Sesions, but wont solve my problem. I already tried to make 2 brand new sites with a clean laravel install, just added the code to see whats in session and what is the session ID. after I reload another laravel site on the same host, ang get back to the original one, session ID is different (that means all session variables are gone). Is it impossible to have 2 laravel sites running on same host and use Session variables?

Last updated 2 years ago.
0

OK, I figured it out. In the session.php there is a variable 'cookie' => 'laravel_session' As the comment explains /* |--------------------------------------------------------------------------

Session Cookie Name
Here you may change the name of the cookie used to identify a session
instance by ID. The name specified here will get used every time a
new session cookie is created by the framework for every driver.
*/

It can't be the same on both sites, and that solve the problem.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Drifeter drifeter Joined 12 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.