ZF-7000: Zend Application Resource Session error

Description

Hi,

When following the example here:

http://framework.zend.com/manual/en/…

{quote} resources.session.save_path = APPLICATION_PATH "/../data/session" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 864000 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" {quote}

throws the following error:

{quote} Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array D:\Server\htdocs\dev\framework\library\Zend\Db\Table\Abstract.php(Line:804): Error #8 Undefined offset: 1 Array' in D:\Server\htdocs\dev\framework\library\Zend\Session.php:445 Stack trace: #0 D:\Server\htdocs\dev\framework\library\Zend\Session\Namespace.php(124): Zend_Session::start(true) #1 D:\Server\htdocs\dev\framework\application\controllers\IndexController.php(9): in D:\Server\htdocs\dev\framework\library\Zend\Session.php on line 445 {quote}

This is due to the keys in primary and primayAssignment not being integers from what I can see. I altered it to this:

{quote} resources.session.save_path = DATA_PATH "/session" resources.session.name = "public" resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" resources.session.saveHandler.options.name = "session" resources.session.saveHandler.options.primary[] = "sessionId" resources.session.saveHandler.options.primary[] = "savePath" resources.session.saveHandler.options.primary[] = "name" resources.session.saveHandler.options.primaryAssignment[] = "sessionId" resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath" resources.session.saveHandler.options.primaryAssignment[] = "sessionName" resources.session.saveHandler.options.modifiedColumn = "modified" resources.session.saveHandler.options.dataColumn = "data" resources.session.saveHandler.options.lifetimeColumn = "lifetime" resources.session.saveHandler.options.lifetime = 864000 {quote}

And it worked as expected

Comments

Component assigned

Still exists in 1.9 RC1

Reassigned to @Freeaqingme

I can confirm this issue in ZF 1.10.5

Using the mentioned solution: resources.session.saveHandler.options.primary[] = "sessionId" resources.session.saveHandler.options.primary[] = "savePath" resources.session.saveHandler.options.primary[] = "name" resources.session.saveHandler.options.primaryAssignment[] = "sessionId" resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath" resources.session.saveHandler.options.primaryAssignment[] = "sessionName

helped with 'Zend_Session_Exception but now I have {{Fatal error: Exception thrown without a stack frame in Unknown on line 0}} error at the bottom of every page...

@Ernest Provides more information about the reported above. How structure of the DB, where is saved the session, the Adapter of the DB used.

To what we can reproduce.

Yes, sorry for that:


resources.session.gc_maxlifetime = 1200
resources.session.use_cookies = 1
resources.session.use_only_cookies = 1
resources.session.cookie_httponly = 1
resources.session.name = ICSESS
resources.session.save_path = APPLICATION_ROOT "/data/sessions"
resources.session.remember_me_seconds = 3600
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.sequence = Off
resources.session.saveHandler.options.name = "system_session"
resources.session.saveHandler.options.primary[] = "session_id"
resources.session.saveHandler.options.primary[] = "save_path"
resources.session.saveHandler.options.primary[] = "name"
resources.session.saveHandler.options.primaryAssignment[] = "sessionId"
resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath"
resources.session.saveHandler.options.primaryAssignment[] = "sessionName"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "session_data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"

CREATE TABLE `system_session` (
    `session_id` char(32) NOT NULL,
    `save_path` varchar(32) NOT NULL,
    `name` varchar(32) NOT NULL DEFAULT 'ICSESS',
    `modified` int,
    `lifetime` int,
    `session_data` text,
    PRIMARY KEY (`session_id`, `save_path`, `name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Using Zend_DB PDO_MYSQL adapter (with MySQL 5.1).

I just found a problem. Session save path was longer than 32 chars, so the string was truncated in save_path column (why do one needs save path, if there is nothing saved in that folder, or is it?). The solution was to alter save_path column to higher values to allow longer paths.

Now it works with the settings above, but not with those proposed in ZF Manual as Jason reported.

Thank you!

Fixed with r23177