Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shreyas's avatar

Session Timeout before session expires

I am new to Laravel and I have been working on a project built on Laravel 4.2.

We have an option to allow our customers to set a variable session timeout value, like 30minutes, 1 hour, 2hours etc. For this we have a form that collects the data and using this to update the session.lifetime value. Also we check this

	$session_timeout = $account->getSetting('session_timeout_setting', 120);
	if ($session_timeout)
	{
		Config::set('session.lifetime', $session_timeout);
	}

	$diff = time() - Session::getMetadataBag()->getLastUsed();
	if ($diff > $session_timeout * 60)
	{
		Session::invalidate();
	}

The session driver is Redis.

This works fine for most of our users, but some of them complain they are getting logged out much earlier. I have put logs inside just before the invalidate and it is not logged there.

I have tested and sometimes it logs me out and sometimes it works fine. Appreciate any help in debugging the issue.

Thanks

0 likes
0 replies

Please or to participate in this conversation.