Issue Type: Improvement Created: 2012-10-09T17:38:30.000+0000 Last Updated: 2013-04-05T16:07:13.000+0000 Status: Closed Fix version(s): Reporter: Vestigal (vestigal) Assignee: Ralph Schindler (ralph) Tags: - Zend_Session
Related issues: Attachments:
On Ubuntu, garbage collection for sessions is taken care of by a cron job, rather than within PHP. If one downloads the PHP packages from Ubuntu's repository, then session.gc_probability in php.ini is set to 0, so PHP never runs the garbage collection for sessions. Unfortunately, if one changes session.gc_probability to something else, then one randomly encounters errors when the session garbage collection is run.
The error is something like this:
<pre class="literal"> Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' in /asps/www/library/Zend/Session.php:462 Stack trace: #0 /asps/www/library/Zend/Session/Namespace.php(143): Zend_Session::start(true) #1 /asps/www/library/Zend/Auth/Storage/Session.php(87): Zend_Session_Namespace->_construct('Zend_Auth') #2 /asps/www/library/Zend/Auth.php(91): Zend_Auth_Storage_Session->_construct() #3 /asps/www/library/Zend/Auth.php(141): Zend_Auth->getStorage() #4 /asps/www/application/layouts/scripts/layout.phtml(8): Zend_Auth->hasIdentity() ...
The issue appears to be that garbage collection is failing, and this causes Zend Framework to think that a session has already been started. The easiest way to test this that I've found is to set session.gc_probability to 1 and session.gc_divisor to 1, so that the error is triggered every time one tries to start a session. With the default values, the error usually only shows up once every hundred times the page loads. Of course, you'll need to be testing this on Ubuntu with one of their PHP packages to see this error.
It would be nice if errors could not be thrown in this case, or if the error message could be more descriptive. It took awhile to track down the cause of this error, but I eventually found the answer on Stack Overflow.
Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:13.000+0000
This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/25
Have you found an issue?
See the Overview section for more details.