开发者

How can I keep Zend Framework from wiping out an existing Session?

I've been given the not fun task of trying to marry a Zend framework instance to antique legacy code with out much modifying the legacy code. Part of this is a multipage form that takes in a heap of data, verifies it, processes it and then sends it to the websites owner in an e-mail. My job is to get that data into ZF where I can auto process it into a database. I cannot use POST. I'd rather like to avoid using an autosubmitting form as I don't think I'm supposed to be using Javascript. Get would be painfully unwieldy.

My hope was to get the data out of the existing form processor and into ZF using the Session. The data is already in the Session in the form processor. At first, I figured it'd be a simple matter of redirecting into my ZF instance (which exists inside a subdirectory of the main website). It's the same domain, ought to be the same session, right?

Well, something about the way ZF handles its sessions causes the old session data to be completely and utterly wiped out. Its just gone.

So does ZF handle its Session in such a way that it wipes out the existing session or is this a fluke? If this isn't a fluke, how can I bypass it? And if it is, what might be causing it/how can I fix it?

Edit

I am using Zend_Session_SaveHandler_DbTable for database backed sessions. This is initialized in the application.ini. Here is the initializing code:

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "Sessions"
resources.session.saveHandler.options.primary = "sessionID"
resources.session.saveHandler.options.modifiedColumn = "lastModifiedTime"
resources.session.saveHandler.options.dataColumn = "data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"

Where I am using the session, I have tried calling session_start(), but that creates an error. Probably because the save handler code has already initialized the session, or does so later. If I try to access the $_SESSION variable directly, I can an error indicating I attempted to access an unset variable. If I create a Zend_Session_Namespace first and then 开发者_运维知识库attempt to access $_SESSION, I am faced with an empty session.


Because you have ZF set up to save sessions to the database instead of the filesystem, having scripts that don't use the same ZF bootstrap code try to invoke the session will fail. (Even then, they could also be using two entirely different session cookie names...)

Because you've implied that the ZF bits are new, then the solution is simple: Stop using the session bits of ZF for now. This means no database table saving, no namespace handler, nothing. Work with the raw $_SESSION superglobal, and use the same session settings as the legacy code. This is the only way to make sure that both applications get access to the same session data without modifying the legacy code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜