Zend_Auth 使用 Zend_Session 而不是默认存储?
我正在阅读本教程,并且在代码中的某个时刻,从数据库中检索用户信息并为用户创建一个会话:
// the default storage is a session with namespace Zend_Auth
$authStorage = $auth->getStorage();
$authStorage->write($userInfo);
我尝试了此操作,但是一旦浏览器关闭,该会话就会过期。所以我的问题是如何将其与 Zend_Session 结合起来创建一个持续 20 天或其他的 cookie?我无法通过 Zend_Session 文档弄清楚。
任何帮助都值得赞赏! 谢谢
I was reading through this tutorial, and at one point in the code, the user info is retrieved from the database and a session is created for the user:
// the default storage is a session with namespace Zend_Auth
$authStorage = $auth->getStorage();
$authStorage->write($userInfo);
I tried this, but this session expires once the browser is closed. So my question is how do I combine this with Zend_Session to create a cookie that lasts for 20 days or something? I can't figure it out through the Zend_Session documentation..
Any help is appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要混合两个不同的任务。您的一项任务是“身份验证”,另一项任务是“记住我功能”。
因此,不要试图一次性解决这些问题。
请记住,我使用一些随机散列存储另一个 cookie,并保留一个将每个随机散列与特定
user_id
关联起来的表。另外,这里有很多关于“记住我”实现的讨论:http://www.google.ru/search?q=site%3Astackoverflow .com+remember+me&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ru:official&client=firefox
Don't mix 2 different tasks. One task you have is "authentication", another is "remember me feature".
So don't try to solve them in one shot.
For remember me store another cookie with some random hash and keep a table that assotiates each random hash with particular
user_id
.Also, it is a lot of discussions about "remember me" implementations here at SO: http://www.google.ru/search?q=site%3Astackoverflow.com+remember+me&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ru:official&client=firefox