I run multiple websites from a single laravel app. Is it possible to have different session lifetimes for them?
E.g. one site should have the standard 2 hours and another should be 1 year
I run multiple websites from a single laravel app. Is it possible to have different session lifetimes for them?
E.g. one site should have the standard 2 hours and another should be 1 year
You can set a variable for each domain in the .env file:
SESSION_LIFE_TIME=160
and call this variable in your config file:
'lifetime' => env('SESSION_LIFE_TIME', 120),
Hope this works for you.
config/session.php
'lifetime' => 120
Create Session_life table in database server and add session lifetime value for particular website.
In controller where your login functionality set lifetime comes from table:
$sl = Session_life ::where('website', "www/test1.com")->first();
$defaultSession = $sl->session_value;
$request->session()->put('lifetime', $defaultSession);
config()->set('session.lifetime', $defaultSession);
config(['session.lifetime' => $defaultSession]);
Here, Session_life is table name, session_value is lifetime value store in table.