Reputation: 1411
I am working with Laravel. My question is in Laravel any way to manage specific session with specific expire time.
I extends session expire time from session.php but here it's apply on all session.
For example I want to manage Login session for 1 week or specific time and other session should be expire after 1 hour or normal time like close browser.
Upvotes: 3
Views: 2013
Reputation: 146
You could try saving date of session's assignment to user. Let's have an example of a user name.
Having mysql table session
of id,user_id,session_name and created_at you could simply do something like:
$s = new Session;
$s->user_id = $user_id;
$s->session_name = 'name';
Then later on in you app you could simply check if time between NOW and $s->created_at is greater than value you are interested in (like 7 days or so). If so - delete the record and delete session by doing:
session()->forget($s->session_name);
EDIT
You can also add a column of duration so you can dynamically forget sessions after time passed out.
Upvotes: 2