Strange behaviour of Laravel Sessions and How I overcome it.

1440300377000 php laravel

by Start Bootstrap


I recently met a strange behaviour from laravel where i am getting logged out in certain minutes, though i have set the expiration of the session
for a very long time.

Few of my office mates (Mr.Manoj) and other suffered the same issue recently.

To handle it, I tried to follow the bad practise of setting the user id in local storage and getting it each time.

Then i planned to overcome in some legal hacks,

After few close analysis of browser i noted that laravel is creating a session named as ‘laravel_session’ in evrey login and destroying
it the same in logout.

I just made the simple hack

Step 1 :

Open the session handler file.

It should be under config->session.php

Step 2 :

Renamed the name ‘laravel_session’ to my project name

'cookie' => 'bizarrechat_laravel_session',

And the Problem was solved !!

So, It will create the session with suffix to project name.

Note : You can dig the source file to explore a bit more