[英]PHP Session Keep Alive
Once my users login, i create a PHP session for them and store the user id in the session. 用户登录后,我将为他们创建一个PHP会话并将用户ID存储在该会话中。 But sometimes the user's session times-out and the time is not really predictable as it happens at different times.
但是有时用户的会话超时,并且该时间实际上是不可预测的,因为它发生在不同的时间。 A user is sometimes doing something on the site which takes time before they press save at this point the session times out.
用户有时会在网站上做某事,这需要一定时间才能按保存,此时会话超时。
I have a jQuery keepAlive function that calls a file name keepAlive.php every x amount of seconds. 我有一个jQuery keepAlive函数,它每x秒调用一次文件名keepAlive.php。 But not sure what code to put in the php file to keeep the php session alive.
但不确定要在php文件中放入什么代码来保持php会话的生命。 Any ideas?
有任何想法吗? Should i just do start_session() and thats it?
我应该只做start_session()就是这样吗?
Thanks 谢谢
The lack of the predictability has to do with your garbage collection settings (see http://www.php.net/manual/en/ref.session.php for the long description). 缺乏可预测性与您的垃圾收集设置有关(有关详细说明,请参见http://www.php.net/manual/en/ref.session.php )。 But the killing of old sessions happens by a random chance that then kills every session older than a certain time.
但是,杀死旧会话的机会是随机的,然后杀死比特定时间更旧的每个会话。
to start the session all you need is start_session() 要开始会话,您只需要start_session()
but if you need things to last longer then you should probably change your php.ini to extend how long it starts before they get killed. 但是,如果您需要使事情持续更长的时间,那么您可能应该更改php.ini,以延长它被杀死之前的启动时间。 (session.gc_maxlifetime)
(session.gc_maxlifetime)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.