I cannot reproduce this ex开发者_JAVA技巧ception when I want. It just happens once in a while, while testing site navigation. It could happen at any page, without the user being logged in or not, no matter.
Totally lost with this error.
Can I, at least, have a help about where should I look at in order to see what could be wrong?
In Zend where do we setup the temp directory for storing session variables?
Thanks,
MEMI had this problem recently on Dreamhost. I boiled it down to the session path isn't writable. I emailed Dreamhost support and they were unresponsive, so I needed to change the path of where sessions were being saved in the filesystem.
in application.ini:
resources.session.save_path = APPLICATION_PATH "/../tmp/session"
This fixed the exception for me. I hope it works for you too!
First, make sure php isn't auto-starting.
php.ini (or ini_set in your index.php):
session.auto_start = 0
Second, don't use session_start() or Zend_Session::start() before you have to. And if you do use them, you can only use them once or you'll get an session already started error.
Third, try to only use Zend_Session_Namespace when you need it and not even use the start commands at all above. (in controllers mostly)
Fourth, you can configure the session resource using your application.ini
resources.session.save_path = APPLICATION_PATH "/../data/session"
resources.session.use_only_cookies = true
resources.session.remember_me_seconds = 864000
More on the resource: http://framework.zend.com/manual/en/learning.multiuser.sessions.html
Hopefully that helps :)
This seems to be related to a session cleanup task that Zend tries to perform. By default apache only has write access to the session directory (on an Ubuntu box it would be /var/lib/php5). This causes the cleanup to fail, resulting in intermittent HTTP/500 errors.
Easiest is to give read access to apache by doing either of
chmod a+r /var/lib/php5
chgrp www-data /var/lib/php5; chmod g+r /var/lib/php5
The above commands assume you're running Ubuntu. In other distros, adjust the username/path.
This error occurs when session_start()
has been called before Zend_Session::start()
, or when the PHP config flag session_auto_start is enabled. Make sure the flag is disabled and your code (or any libraries you use, besides ZF) is not calling session_start()
.
If you are developing applications with the RPCL library (RADPHP) and you are getting this error:
Application raised an exception class Zend_Session_Exception with message 'session has already been started by session.auto-start or session_start()',
then here is my solution.
You will be surprised how simple it is. Simple include the line
require_once("zcommon.inc.php");
just after the opening PHP tag in the file containing ZAuth component – usually this is the file with a DataModule form. Of course make sure the file zcommon.inc.php is in your path. This will ensure that the Zend session will start first instead of the RPCL session.
Also make the name of the php files in your application correspond to the name of the containing classes.
Are you on a Debian/Ubuntu machine?
If so, your problem could be related to automatic garbage collection of sessions. Try disabling it by setting this in your php.ini file:
session.gc_probability = 0
See http://somethingemporium.com/2007/06/obscure-error-with-php5-on-debian-ubuntu-session-phpini-garbage for more info.
Do what Aron said add:
resources.session.save_path = APPLICATION_PATH "/../temp/session"
to application ini. Make sure you have the folder. Worked for me!
I also added:
phpSettings.session.auto_start = 0
to application ini. Not sure if that helped.
精彩评论