Issues

ZF-7000: Zend Application Resource Session error

Issue Type: Docs: Problem Created: 2009-06-12T13:07:18.000+0000 Last Updated: 2010-10-20T10:07:19.000+0000 Status: Resolved Fix version(s): - 1.11.0 (02/Nov/10)

Reporter: Jason Brumwell (baxter) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Application

Related issues: - ZF-6868

Attachments:

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

Posted by Thomas Weidner (thomas) on 2009-07-09T23:37:18.000+0000

Component assigned

Posted by David Abdemoulaie (hobodave) on 2009-07-30T19:06:13.000+0000

Still exists in 1.9 RC1

Posted by Ramon Henrique Ornelas (ramon) on 2010-04-02T17:07:59.000+0000

Reassigned to @Freeaqingme

Posted by Ernest Szulikowski (est) on 2010-06-07T04:44:53.000+0000

I can confirm this issue in ZF 1.10.5

Posted by Ernest Szulikowski (est) on 2010-06-07T05:05:16.000+0000

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

Posted by Ramon Henrique Ornelas (ramon) on 2010-06-07T07:08:57.000+0000

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

Posted by Ernest Szulikowski (est) on 2010-06-07T07:42:06.000+0000

Yes, sorry for that:

<pre class="highlight">
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"



<pre class="highlight">
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!

Posted by Ramon Henrique Ornelas (ramon) on 2010-10-20T10:02:39.000+0000

Fixed with r23177

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts