Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Session timeout even when user is active #7783

Open
gFaro opened this issue Jun 22, 2018 · 6 comments
Open

Session timeout even when user is active #7783

gFaro opened this issue Jun 22, 2018 · 6 comments

Comments

@gFaro
Copy link

gFaro commented Jun 22, 2018

Hi guys, I have been searching for a zend functionality that prevents the session from timing out if the user is still active for example clicking things.

I would rather use a zend implementation if available than write custom code. However, I am not sure this feature is available.

@alenoosh
Copy link

I have the same problem, I use zend framework 3. Have you found a solution for this issue or not ?

@gFaro
Copy link
Author

gFaro commented Aug 22, 2018

I used a resource I found on zend framework 2 with some modifications.
Here is the link: http://blog.tulikowski.com/zend-framework-2-implementation-of-session-authentication-timeouts/
I added the below code in my onBootstrap. I think I made some other additions to get it working but can't remember all as it has been sometime.
$authStorage = $sm->get('AuthSessionStorage'); $authService = $sm->get(\Zend\Authentication\AuthenticationService::class); if($authStorage->isExpiredAuthenticationTime()) { $authStorage->clearAuthenticationExpirationTime(); $authService->clearIdentity(); } else { $authStorage->setAuthenticationExpirationTime(); }

Hope it helps.

@tasmaniski
Copy link

Are you using Ubuntu as a server?

@gFaro
Copy link
Author

gFaro commented Aug 22, 2018

No. I am using an apache server in with centos. Why?

@tasmaniski
Copy link

Ubuntu (and Debian distributions) has behavior to delete all sessions after X minutes with cron job, I think 2 4 mins is bay default.

So, basically you need to change that behavior in php.ini file,
but php.ini for cli!

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 1440

Try to increase this number.
Also, check your config for the session in php.ini files,
because maybe you have a config that override one from your application.

@alenoosh
Copy link

Thanks @gFaro for your quick reply

@tasmaniski Yes I use ubuntu, ok I'll check this to see whether this solves the issue for me. Thanks alot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants