通过 Zend_Application 配置 Zend_Session
所以我使用 Zend_Tool 构建了一个站点模板,并将这些参数添加到 application.ini
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "session"
resources.session.saveHandler.options.primary.session_id = "session_id"
resources.session.saveHandler.options.primary.save_path = "save_path"
resources.session.saveHandler.options.primary.name = "name"
resources.session.saveHandler.options.primaryAssignment.sessionId = "sessionId"
resources.session.saveHandler.options.primaryAssignment.sessionSavePath = "sessionSavePath"
resources.session.saveHandler.options.primaryAssignment.sessionName = "sessionName"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "session_data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"
问题似乎不在于会话资源或被调用的 saveHandler,而是似乎 PHP / Zend 甚至没有尝试在数据库中设置我的会话。
除非我删除会话资源所需的选项,并且我已在不同的 Zend 类中进行检查以查看它们是否正在运行,否则我不会收到任何错误;他们就是这样。
我当前的猜测是,我需要更改 php.ini 中的某些内容,以便 Zend_Session 能够覆盖默认会话处理。我使用 Zend Server 进行此测试。
响应
我检查了 session.auto_start 并将其设置为 0。
我还通过不使用任何数据库处理程序来测试它,而只是尝试更改也失败的路径。
从我的设置来看,正在调用 Zend_Session_SaveHandler_DbTable::__construct,并且我的 resources.db 设置位于我的会话之上,并且适用于其他所有内容。
除此之外,目前我的 saveHandlers.options 数据设置不正确,并且我在 StackOverflow 上看到了其他帖子,这些帖子与由于 saveHandler 配置错误而导致的错误有关。
正如我上面所说,我认为这与 PHP 没有调用传递的函数进行会话处理有关。我知道如果您想设置自己的会话管理,您可以连接这些调用并提供要在每个状态(打开关闭读写等)上执行的回调函数。
我只是对 PHP.ini 设置了解不够,不知道是否需要启用特定设置才能允许修改会话管理。
So I built a site template using Zend_Tool and added these parameters to the application.ini
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "session"
resources.session.saveHandler.options.primary.session_id = "session_id"
resources.session.saveHandler.options.primary.save_path = "save_path"
resources.session.saveHandler.options.primary.name = "name"
resources.session.saveHandler.options.primaryAssignment.sessionId = "sessionId"
resources.session.saveHandler.options.primaryAssignment.sessionSavePath = "sessionSavePath"
resources.session.saveHandler.options.primaryAssignment.sessionName = "sessionName"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "session_data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"
The problem doesn't seem to be with the session resource or the saveHandler being called, but instead it seems as if PHP / Zend don't even try to setup my session in the database.
I get no errors unless I remove an option that is required by the session resource and I've placed checks in different Zend classes to see if they were getting run; which they are.
My current guess is that I need to change something in php.ini in order for Zend_Session to be able to override the default session handling. I'm using Zend Server for this test.
Responses
I checked session.auto_start and it was set to 0.
I've also tested it by not using any database handlers and instead just tried changing the path which also failed.
From what I can tell with my setup the Zend_Session_SaveHandler_DbTable::__construct is being called and my resources.db settings are above my session and are working for everything else.
Besides all that currently I have the saveHandlers.options data setup incorrectly and I've seen other posts on StackOverflow which pertain to errors due to bad saveHandler configs.
As I said above I think it has something to do with PHP not calling the passed functions for session handling. I know if you want to setup your own session management you can hook up to these calls and provide callback functions to be executed on each state (open close read write etc).
I just don't know enough about PHP.ini settings to know if there are specific settings that need to be enabled to allow session management to be modified.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在引导程序中尝试一下:
您还可以尝试将我的补丁应用到 Zend_Session 以查看该会话已经启动,并且您无法更改 savehandler: http://framework.zend.com/issues/browse/ZF-7915 。我不记得所有细节,但这些组件有些不兼容......
Try this in your bootstrap:
You can also try to apply my patch to Zend_Session to see that session is already started and you can't change savehandler: http://framework.zend.com/issues/browse/ZF-7915 . I do not remember all details, but there is some incompatibility in these components...
当对会话使用数据库处理程序时,您必须 确保数据库在会话资源之前初始化。数据库连接将在引导期间设置为处理程序作为适配器。如果这不能解决问题,请尝试设置 会话处理程序手动并且确保
session.auto_start< /code> 在 PHP.ini 中被禁用
When using the DB handler for sessions, you have to make sure the DB is initialized before the Session Resource. The db connection will be set to the handler as adapter during bootstrap. If this does not solve the issue, try setting up the Session handler manually and also make sure
session.auto_start
is disabled in PHP.ini