views:

119

answers:

4

I have a flash upload script, that uses a .php file as the processor. I need the processor file to set a cookie with a gallery ID that was created by php script, and pass it on to the confirmation page. Except when Flash runs the php file... it doesnt set the cookie. It does set the session variable, which was good enough, but now Im using lighttpd for the site (including the confirmation page) and apache for the actual uploader processor script (because lighttps sucks at uploading large files), so the session vars don't get transferred between the 2 server software.

How can I transfer a variable from the php processor (running on apache) to a confirmation page running lighttpd?

+1  A: 

Well I would assume that it doesn't set a cookie as it was called by a flash script not a browser, and cookies are stored by the browser.

The only ways I can think of are a mysql database, or simply a text file.

Nico Burns
A: 

I second Nico's solution. Store the session data in the database and that way PHP scripts running under both lightty and apache can access the SID

Josh
A: 

Just thought of a second solution which is probably less efficient than Nico's but may be better suited to you. If the cookie being sent to Flash isn't being sent to the browser also, you could use Flash's ExternalInterface class to pass the contents of the cookie to a javascript function which would set the cookie in the browser. Or you could call a javascript function which will make an AJAX call to fetch the contents of the cookie.

Josh
A: 

Not sure if we're doing the same thing, but I had a similar problem, not being able to set a cookie from a php script run through flash. However I later realized it failed because I was missing arguments.

flash.swf:
sendToURL('script.php?val=dataFromFlash');

script.php:
//setcookie('flashData', $_GET['val']); //this did not work
setcookie('flashData', $_GET['val'], '0', '/'); //this worked

The PHP manual says that only the name argument is required, but I had to specify the expire and date arguments to get this to work. Perhaps this is because, as Nico's answer indicates, it is not sent through a browser? Anyway, hope this helps.

jodeci