Codeigniter: User session keeps expiring

邮差的信 提交于 2019-12-22 10:33:08

问题


I'm using CodeIgniter, and I'm having a small issue with sessions. I've set 'sess_expiration' in config.php to 0 so that the user session will never expire, yet users -even myself- are still occasionally kicked out and asked to login again! (i'm storing sessions in the DB btw)

The way I validate a user's session is by basically checking if user_id (which I've previously stored in the session is TRUE or FALSE. If it's FALSE then it asks them to login again.

Any idea what could be forcing sessions to expire?

Appreciate your help :)


回答1:


Try setting the session expire to some really large number. Try:

time()+(3600*24*365*5)

or

time()+157680000;

This session should last you 5 years.




回答2:


If you're making AJAX requests in your app/site I think this may be the issue you are experiencing: https://github.com/EllisLab/CodeIgniter/issues/154

It seems to be a bug in how CI handles AJAX requests updating sessions.



来源:https://stackoverflow.com/questions/5500516/codeigniter-user-session-keeps-expiring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!