我们如何使 Zend 会话存储在可用方法中持久化?

发布于 2024-11-19 05:53:20 字数 604 浏览 3 评论 0原文

我对 Zend 身份验证会话存储系统有点困惑。我会尽力解释我的问题。请尝试表达您的意见或您对 zend session 的了解或我的假设和问题。

默认情况下,Zend_Auth_Adapter_DbTable 在成功验证后返回提供给 auth 对象的身份。 如果我使用 getStorage() 或 getIdentity(),那么我可以检索某些变量的“会话值(id,名称,..)”。 !! 如果您认为以上两个假设都是正确的,那么我的问题是,

  1. 会话值默认存储在哪里? (默认情况下,它使用哪个位置来存储会话?)
  2. 如果我指定会话保存路径,如下所示。如果会话按照问题1存储,为什么我们需要将这些会话存储在文件夹中? save_path = /home/myaccount/zend_sessions/myapp
  3. 如果我使用 Zend_Session_SaveHandler_DbTable。是什么使它比上述两种选择更好?
  4. 或者,您能否提出您的想法,我们可以使会话在 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,

  1. Where session values stores by default? (By default, which place it uses to store the session?)
  2. 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
  3. if I use Zend_Session_SaveHandler_DbTable. What makes it better than above two options?
  4. 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 技术交流群。

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

发布评论

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

评论(2

坦然微笑 2024-11-26 05:53:20

我不是 100% 确定你的问题,但我会尝试回答:-)

  1. 在默认的 linux 机器上,它应该是 /tmp 或 php.ini 中配置的任何内容
  2. 考虑共享托管环境(安全问题)
  3. Zend_Session_SaveHandler_DbTable 很好,如果你有,例如,负载平衡的Web服务器,因此用户的会话独立于他连接到的Web服务器
  4. 如果您只使用一台服务器(不共享),并且不需要诸如“谁是”之类的功能online”,文件系统上的默认会话处理是最好的解决方案(在我看来)。

Iam not 100% sure about your question but i will try to answer :-)

  1. On an default linux box it should be /tmp or whatever is configured in php.ini
  2. Think about shared hosting environements (security issues)
  3. Zend_Session_SaveHandler_DbTable is nice if you have, for example, load balanced web servers, so the user has his session independent of the webserver he is connected to
  4. If you use only one server (not shared), and have no need for functions like "who is online", default session handling on filesystem is the best solution (in my opinion).
沫雨熙 2024-11-26 05:53:20
  1. Zend会话内部使用php全局变量$_SESSION,会话保存的路径由php.ini设置控制,因此您可以使用session_save_path

  2. 对于 session_save_path,您可以指定需要保存会话的文件夹名称。默认情况下,会话存储在临时文件夹中,每次有人清除临时文件夹时,会话数据都会丢失。所以最好使用其他文件夹。

  3. 数据库会话用于会话共享。在像谷歌这样的大型网站中,一台服务器不会满足所有用户的请求,因此如果您请求某些内容,会话将被创建并且您将得到响应,对于您的下一个请求,不能保证您会访问同一台服务器,在这种情况下第二台服务器尝试从某些分布式位置(例如数据库或内存缓存)获取会话数据。对于分布式会话,Memcache 是比 db 更好的选择,因为它更快。

  4. 您试图在会话中保存哪些信息,如果您想保存更长时间,那么为什么不能将该信息与用户对象关联,而不是保存在会话中。

  1. 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

  2. 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.

  3. 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.

  4. 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.

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