Welcome Guest, Not a member yet? Register   Sign In
Adobe Flash and CI's Session class.
#1

[eluser]mrbinky3000[/eluser]
I'm using CodeIgniter for a project that allows logged in users to upload files to their user accounts. While I do appreciate CI's built in Upload functions, I wanted to allow users the option to use SWFUpload as an alternate means up uploading files.

SWFUpload is an open source Shockwave Flash (Adobe Flash, Macromedia Flash) file uploading tool. It allows users to upload multiple files at once and provides a more "web 2.0-ish" look via Ajax and such.

My problem is this. I'm using the wonderful DX_Auth CodeIgniter library to manage my users credentials and provide security. DX_Auth uses CodeIgniter's Session class to store a session variable.

Everything works fine when I upload files using a normal HTML form and CodeIgniter's Upload class. By that, I mean the user's credentials are checked and the file is stored in the appropriate user's account.

It would seem that Flash acts like a separate browser. As far as CodeIgniter is concerned, it is a seperate entity and does not use CI's session cookie. The Flash has no knowledge of CodeIgniter's Session cookie. It does not read it and does not pass it along to my PHP. So, DX_Auth does its job and denies any file uploads via Flash.

SWFUpload allows me to send any post vars I want along with the file being uploaded.

I plan to send CodeIgniter's session cookie along with the file being uploaded as a POST var. Then, in the controller, parse the POST vars. My problem is this...

Is there a way to manually force CodeIgniter to use my session cookie information instead of it's own?

Thanks in advance for any advice.
#2

[eluser]WanWizard[/eluser]
From the top of my head:

In the code that generates the view for swfupload, add the value of the session cookie as a post variable. You can retrieve the session cookie using:
Code:
$session = $this->input->cookie($this->session->sess_cookie_name);

Then, in the controller that processes the swfupload, get the session cookie from the post, and store it:
Code:
$_COOKIE[$this->session->sess_cookie_name] = <value retrieved from the post here>;

Followed by a manual call to the session library to read the session:
Code:
$this->CI->session->sess_read();
If you do this directly after the session library has been loaded, but before your authentication code kicks in, this should work.
#3

[eluser]Udi[/eluser]
I just blogged about it,
My solution was posting the session data with the files through SWFUpload.




Theme © iAndrew 2016 - Forum software by © MyBB