Saturday, June 15, 2013

Integrating SWFUpload into CakePHP 2.0 with AuthComponent

I'm not sure what changed with 2.0, but the scheme that worked in CakePHP 1.2 to integrate SWFUpload no longer works in 2.0. With the old scheme, you pass the session ID to beforeFilter and connect with the existing session by setting the ID and starting the session. It's explained here: http://xpnce.com/?p=69

For whatever reason, this no longer works. I struggled for a while and finally found a solution that works:

public function __construct($request = null, $response = null) {
if(isset($_POST['PHPSESSID'])) {
Configure::write('debug', 0);
session_id($_POST['PHPSESSID']);
}
   parent::__construct($request, $response);
}

It appears that the main issue is that, with CakePHP 2.0, the session is started before "beforeFilter" and "startupProcess" methods, and once started, assigning an existing ID does not allow you to connect to the existing session. By the time those methods are called, a new session has already been created, and assigning an existing ID simply replaces the new ID with the old. So, I had to override the constructor to get the ID set before the session is created.

I wanted to share this info in case someone knows a better way to do this, and in case anyone else is struggling with it.

Best,
Dyske


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: