我们如何使 Zend 会话存储在可用方法中持久化?
我对 Zend 身份验证会话存储系统有点困惑。我会尽力解释我的问题。请尝试表达您的意见或您对 zend session 的了解或我的假设和问题。
默认情况下,Zend_Auth_Adapter_DbTable 在成功验证后返回提供给 auth 对象的身份。 如果我使用 getStorage() 或 getIdentity(),那么我可以检索某些变量的“会话值(id,名称,..)”。 !! 如果您认为以上两个假设都是正确的,那么我的问题是,
- 会话值默认存储在哪里? (默认情况下,它使用哪个位置来存储会话?)
- 如果我指定会话保存路径,如下所示。如果会话按照问题1存储,为什么我们需要将这些会话存储在文件夹中? save_path = /home/myaccount/zend_sessions/myapp
- 如果我使用 Zend_Session_SaveHandler_DbTable。是什么使它比上述两种选择更好?
- 或者,您能否提出您的想法,我们可以使会话在 Zend 中持久存在?目前我们有100万注册用户,那么我们如何才能高效地存储用户的会话呢?
预先感谢所有参与讨论的人,如果您认为我的任何问题或假设是错误的,请尝试表达您的方式。这样我就能从错误中学习
I am little bit confused about Zend authentication session storage system. I will try to explain my problem. Please try to express your opinion or anything you know about zend session or my assumptions and questions.
By default, Zend_Auth_Adapter_DbTable returns the identity supplied back to the auth object upon successful authentication.
If I use getStorage() or getIdentity(), so I can able to retrieve "Session values(id, name,..)" to some variables. !!
If you think above both assumption are right, my questions are,
- Where session values stores by default? (By default, which place it uses to store the session?)
- If I specify session save path like below. Why should we need to store these session in a folder if session stores according question 1?
save_path = /home/myaccount/zend_sessions/myapp - if I use Zend_Session_SaveHandler_DbTable. What makes it better than above two options?
- Or, can you able to suggest which way you think, we can make the session persistent in Zend ? Currently we got 1 million users registered with us,so how can we make the users session storage in efficient way?
Thanks in advance to all of you who are going to participate in discussion, if you think any of my questions or assumptions are wrong, please try to express your way. So I can able to learn from mistakes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是 100% 确定你的问题,但我会尝试回答:-)
Iam not 100% sure about your question but i will try to answer :-)
Zend会话内部使用php全局变量$_SESSION,会话保存的路径由php.ini设置控制,因此您可以使用session_save_path
对于 session_save_path,您可以指定需要保存会话的文件夹名称。默认情况下,会话存储在临时文件夹中,每次有人清除临时文件夹时,会话数据都会丢失。所以最好使用其他文件夹。
数据库会话用于会话共享。在像谷歌这样的大型网站中,一台服务器不会满足所有用户的请求,因此如果您请求某些内容,会话将被创建并且您将得到响应,对于您的下一个请求,不能保证您会访问同一台服务器,在这种情况下第二台服务器尝试从某些分布式位置(例如数据库或内存缓存)获取会话数据。对于分布式会话,Memcache 是比 db 更好的选择,因为它更快。
您试图在会话中保存哪些信息,如果您想保存更长时间,那么为什么不能将该信息与用户对象关联,而不是保存在会话中。
Zend session internally uses php global variable $_SESSION, the path where the session get saved is controlled by php.ini settings, so you can use session_save_path
For session_save_path you can give folder name where you need to save session. By default session stores in temp folder, every time somebody clears temp folder sessions data will be lost. So its better to use other folder.
Db sessions are used for session sharing. In large websites like google, one server wont serve all users requests, so if you requested something, session will get created and you will get response, for your next request there is no guarantee that you will hit the same server, in that case the 2nd server tries to fetch the session data from some distributed location like db or memcache. Memcache is best option than db for distributed session, as it is more faster.
What information you are trying to save in session, if its something you are trying to save for longer time then why can`t you associate that information with user object instead of saving in session.