CDbHttpSession problem

I have an action that accepts uploads from a Flash-based upload component.

Because Flash has a separate HTTP session from the browser, the common technique is to put your PHP session id in the POST along with the upload, so that’s what I did, and it worked fine for a long time.

In the action that accepts the POST from Flash, I use the following code to restore the session:

    Yii::app()->session->sessionID = $_POST['SESSION_ID'];


Pretty straight-forward stuff.

Recently, we switched to CDbHttpSession as the session manager component for this application - everything else works normally, but the above technique no longer works.

Rather than restoring the existing session data, when I use the code above, it "resumes" with the existing session ID, but clears out all the existing session data! So you get session with the correct ID, but all your session data is gone - and on the next page load in the browser itself, you are then redirected and prompted to log in again…

Could this be a bug in CDbHttpSession?

Or is there a different technique that will enable me to correctly resume a session with a given ID?

Did you try to set the session id as parameter for the session component in your main config instead? I can imagine that it’s too late to set it in the controller action. You might need some small logic to only set it for flash requests.

CHttpSession::init() only does $this->open() if the "autoStart" configuration option is set to true, otherwise it does nothing. I do not have "autoStart" enabled in this application.

And CDbHttpSession does not override init().

I’m not even completely sure why you should need to manually call init(), since it’s automatically called when the application component initializes, e.g. the moment you try to access it and set the session id. I just saw that done in an example somewhere.

Hmm, ok. So did you try some debugging? With your experience it shouldn’t be that hard to find out what’s causing the trouble, right? ;)