2009年5月6日星期三

[fw-mvc] Zend_Session & expiration hops & .htaccess default file

Hi all,
This is not a question but simply to share what I've just painfully learnt trying to figure out why Zend_Session_Namespace failed to serve back data on which a 1-hop expiration was set.
It took me 2 hours to find it, I hope it will save time to some people out there.
Situation is the following:
I used Zend_Session_Namespace subclasses to handle session data, with expiration hop of 1 (expiration set on global namespace, not on specific var (ENGH for the purists)).
Problem is that apparently, when running the app, session data was not recovered on next page load and disappeared.
Reason for this is not a ZF bug and is pretty straight-forward, once you know it...
I had a non-existing image inserted in my html code.
New .htaccess/httpd.conf rule for ZF is solely based on whether queried file exists or not, since this image did not exist
 => it was forwarded to my ZF app => generating an invisbile 404 error (not rendered within <img> tag) => burning out my 1-hop lifetime limit => what seemed to be my next page call was in fact my third page call, hence the reason for disappearing session data.
Conclusion: check apache query log when not in prod || modify .htaccess rule to skip all unlikely script urls (.png, .jpeg, .pdf...)
Cheers,
Remy

没有评论: