zend framework losing session
-
03-07-2019 - |
Question
I am trying to implement a Flash uploader in my Zend framework application but I am having problems with the session.
The Flash does not send any cookie headers and this is why the session is lost. I am trying to send the sessionId as a post param and in my bootstrap file I added a session_id($_POST['session_id]) but this doenst seem to work.
I am using a MySQL table as session storage
I tryed to debug the error and as far as I see, the session_id is set, and the storage returns the corect data from the database but it doesn't seem to be set correctly in the $_SESSION global.
And even stranger it seems to work on my Windows computer but not on the Linux staging server.
Solution
Do you know if you are using Suhosin with your PHP installation?
I've heard a few reports of Suhosin doing this to the sessions, solution in this case is to disable suhosin.session.cryptua
in php.ini.
Anyway, if that's not your problem, just to be sure with the basics:
- Make sure you pass your
session_id()
in a post from your Flash, for example, with SWF Upload, this is done by passing it in thepost_params
value of the configuration array. - Make sure you call
session_id($_POST['session_id])
beforesession_start()
But anyway, it is probably related to your PHP installation if you are saying it works under your Windows environment.
OTHER TIPS
This sounds similar to various bugs that have been reported over the years, though in most cases it worked on linux and not on windows.
http://framework.zend.com/issues/browse/ZF-2459 https://www.zend.com/en/forums/index.php?t=msg&goto=16104&S=de7d9b854db445eb37d0f33470cac6b0
and as recently as last month:
http://blog.rac.me.uk/2009/01/09/php-zend-session-dont-set-it-up-in-the-initalizer/
-- MarkusQ
Try the following in your controller action:
session_write_close();
session_id($this->_getParam('PHPSESSID'));
session_start();