开发者

Configuring Zend_Session Through Zend_Application

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 开发者_StackOverflow社区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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜