通过 Zend_Application 配置 Zend_Session

发布于 2024-08-23 14:45:55 字数 1576 浏览 13 评论 0原文

所以我使用 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 技术交流群。

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

发布评论

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

评论(2

半﹌身腐败 2024-08-30 14:45:55

在引导程序中尝试一下:

protected function _initForceSession()
{
    $this
            ->bootstrap('db')
            ->bootstrap('session');
}

您还可以尝试将我的补丁应用到 Zend_Session 以查看该会话已经启动,并且您无法更改 savehandler: http://framework.zend.com/issues/browse/ZF-7915 。我不记得所有细节,但这些组件有些不兼容......

Try this in your bootstrap:

protected function _initForceSession()
{
    $this
            ->bootstrap('db')
            ->bootstrap('session');
}

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

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