Zend 框架会话过早过期 [英] Zend framework session expires prematurely

查看:38
本文介绍了Zend 框架会话过早过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Zend Framework for PHP 并使用 Zend_Session 模块处理会话.这是我的初始化程序(或引导程序)中的内容:

I'm using Zend Framework for PHP and handling sessions with the Zend_Session module. This is what I have in my Initializer (or bootstrap):

Zend_Session::start();
Zend_Session::rememberMe(864000);

864000 秒应该可以持续 10 天,但我仍然在大约一个小时(或者可能更少)被踢出.我已经通过将其设置为 10 秒来测试该语句是否有效,确实我在适当的时间被踢出,但是当我将其设置为非常高的值时,它不起作用!我在这里浏览了一些文档:http://framework.zend.com/manual/en/zend.session.html

864000 seconds should be good for 10 days, but I'm still being kicked out at about an hour (or maybe a little less). I've tested to see if this statement works at all by setting it to 10 seconds, and indeed I am kicked out at the appropriate time, but when I set it to a very high value, it doesn't work! I went through some of the documentation here: http://framework.zend.com/manual/en/zend.session.html

我看到的另一种方法是使用以下方法:

Another method I saw was to use the following:

$authSession = new Zend_Session_Namespace('Zend_Auth'); 
$authSession->setExpirationSeconds(3600); 

现在,我有不同的命名空间.这是否意味着如果我想让它们不过期,我必须为所有这些设置?我还没有测试过这种设置过期时间的方法,但我真的很想看看这里的大师们对解决这个问题的正确方法是怎么说的.非常感谢大家...

Now, I have different namespaces. Does this mean I have to set this for all of them if I want to keep them from expiring? I haven't tested this method of setting the expiration, but I really wanted to see what the gurus on here had to say about what the correct way of approaching this problem is. Thanks a lot guys...

另外,有谁知道我如何才能使会话永不过期?我试过将第二个设置为 0 和 -1,但这会引发错误.

Also, does anyone know how I can make it so that the session never expires? I've tried setting the second to 0 and -1, but that throws an error.

推荐答案

您的客户的计算机时钟、日期和时区需要正确设置,会话过期才能正常工作.否则,时间转换将关闭,并且可能会导致您的 cookie 在访问浏览器的那一刻就过期.

Your client's computer clock, date, AND time zone need to be set correctly for session expirations to work. Otherwise the time conversions are off, and likely causing your cookie to expire the minute it hits the their browser.

这篇关于Zend 框架会话过早过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆