会话管理(Zend Framework 特定)

发布于 2024-08-08 22:36:16 字数 602 浏览 5 评论 0原文

我正在尝试使用 rememberMe() 函数来记住用户并一次保留会话数月。

我读过,如果您通过 rememberMe() 传递一个值,如果会话已经开始,它将不起作用。根据 PHP 手册中的 session_set_cookie_params() 文档,“您需要为每个请求调用 session_set_cookie_params(),并且在调用 session_start() 之前”。

通过我在引导程序中调用 Zend_session::start() ,我认为我应该这样做。我的问题是 rememberMe() 似乎不起作用。

当我调用 session_get_cookie_params(); 时,我得到:

Array([lifetime] => 0 [path] => / [domain] => [secure] => httponly] =>)

有什么想法吗?

I'm trying to get the rememberMe() function to remember users and retain sessions for months at a time.

I've read that if you pass a value through rememberMe() it will not work if the session has already been started. From the session_set_cookie_params() documentation in the PHP manual, "you need to call session_set_cookie_params() for every request and before session_start() is called."

By I am calling Zend_session::start() in my bootstrap as i thought I was supposed to. My problem is that rememberMe() doesn't seem to be working.

When I call session_get_cookie_params(); I get:

Array([lifetime] => 0 [path] => / [domain] => [secure] => httponly] =>)

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗梦空间 2024-08-15 22:36:16

我已经解决了这个问题。会话已被同一服务器上的另一个网站删除,该服务器的会话每 24 分钟就会过期。为了解决这个问题,我将 session.save_path 设置为新文件夹。我还将 session.gc_maxlifetime 和 session.cookie_lifetime 设置为非常大的数字。

问题解决了!

I've solved the problem. sessions were being erased by another website on the same server which expires sessions every 24 minutes. To fix this I set the session.save_path to a new folder. I also set session.gc_maxlifetime and session.cookie_lifetime to be very large numbers.

problem solved!

阳光①夏 2024-08-15 22:36:16

不要使用 start() 方法。如果您使用 MVC,它应该可以正常工作。 session_start 必须在发送任何输出之前调用,并且就在发送响应之前(因为输出缓冲)。会话在第一次使用 Zend_Session_namespace 时自动启动。

Don't use the start() method. It should work fine if you are using MVC. The session_start must be called before any output is send and that's right before sending response (because of outputbuffering). The session is started automatically upon first Zend_Session_namespace usage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文