views:

332

answers:

2

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.

+2  A: 

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

Gordon
see above for response. Synopsis.. I think it has to do with the callback hooks that php allows you to hook into for session management and how for some reason (maybe a setting) they aren't getting used. IE (open close read write).
Ballsacian1
@Ballsacian1 no clue, sorry. You could try to step through the bootstrap process with Zend_Debugger or XDebug to see where it goes wrong.
Gordon
+2  A: 

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

Vladimir
Yea for some reason even though the db was getting created before the session_handler and changing their order resulted in a db exception, not including the __initForceSession in the bootstrap caused your modified Session.php file to flag session as already been set.I'm surprised there wasn't a check already to see if the session had been created.
Ballsacian1