开发者

How to make users not be logged out after certain time (PHP/APACHE)

I already made these adjustments in my php.in file and then stop开发者_高级运维ped/started the server:

; 24 hour session cookie
session.cookie_lifetime = 86400

; Prevent server from cleaning up session
; Some value higher than the cookie lifetime
session.gc_maxlifetime = 200000 

But that seemed to do nothing and my users are still complaining that they get logged out after about 30 minutes. And I am also getting logged out often.

What else could I look into or do in order to make my users who are logged in not to be logged out and keep them logged in at least 24 hours or more.

Thanks!


Whilst you can increase the session time out using code similar to the below: (in .htaccess, if you are on apache)

php_value session.gc_maxlifetime 86400
php_value session.gc_probability 1
php_value session.gc_divisor 100

The problem is that your sessions folder can become cluttered with inactive session files. Our sites use a half hour time out, but we have a an AJAX poller as part of the management interface which keeps the session alive once every 15 minutes. That way we only keep the session open for active users (even if they are perfoming long term operations)

Alternatively you may consider storing a separate - longer term - cookie which can be used to quickly re-establish the users session should it expire, again this prevents the need to fill your server with cumbersome session files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜