Re: Flash & PHP Session




"amygdala" <noreply@xxxxxxxxxxx> schreef in bericht
news:44e95b9a$0$2013$9a622dc7@xxxxxxxxxxxxxxxxxxxx

"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> schreef in bericht
news:i8adnfdQ7qUVk3TZnZ2dnUVZ_qOdnZ2d@xxxxxxxxxxxxxx
Steve Cook wrote:
Jerry Stuckle wrote:

Steve Cook wrote:

Jerry Stuckle wrote:


Steve Cook wrote:


Hi,

I have an upload application written in PHP and Flash. The PHP page
gets the file information via $_POST. Moreover, the user never
actually visits the PHP page, rather Flash sends the information to
the
PHP page and then loads the result, all in the background. Right
now,
the php page cannot access the $_SESSION. Is there anyway that I can
conitnue the PHP session when doing this or does the user have to
visit
the PHP page?

Thanks.

Steve


Looks like your flash isn't sending the session cookie along with the
rest of the request.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================


Do you have an idea how I can get flash to send the session cookie?


I think you're going to have to ask that in a Flash newsgroup. We're
PHP programmers here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================


I definitely know how to pass the session_id via flash. I guess I
should have asked how do I manually set the session_id value in PHP?
In other words how do I populate the session_id variable?


You don't. PHP does, based on the session id passed back by the
browser - which is stored in a cookie.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

I beg to differ:

Do something like:

<?php
ini_set('session.use_cookies', '0');
session_start();
?>

Put your flash movie in the same page and echo the SID behind it (old
school style):

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
width="32" height="32">
<param name="movie" value="whatever.swf?<?php echo SID ?>">
<param name="quality" value="high">
<embed src="whatever.swf?<?php echo SID ?>" width="32" height="32"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer";
type="application/x-shockwave-flash" sid=""></embed></object>

This will give you access to the variable PHPSESSID in flash. Make sure
you append this to every GET request to php.

Notice though that appending session ID's to GET request are often
considered a security risk. But since you are using flash and thus
requests are made in the background (not through addressbar requests),
it's somewhat safer to use IMO.

Cheers


Ooops I didn't thoroughly read the whole thread. I didn't read that a
session was already started.

Forget about the ini_set('session.use_cookies', '0'); part.

And do (untested):

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
width="32" height="32">
<param name="movie" value="whatever.swf?PHPSESSID=<?php echo session_id()
?>">
<param name="quality" value="high">
<embed src="whatever.swf?PHPSESSID=<?php echo session_id() ?>" width="32"
height="32" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer";
type="application/x-shockwave-flash" sid=""></embed></object>

Then in the php page that handles flash requests:

<?php
session_id($_GET['PHPSESSID']);
session_start();
?>

Should do the trick. But maybe I'm overlooking something here.


.



Relevant Pages

  • Re: session hang problem
    ... PHP 5.x.x you don't need to. ... store variables and objects inside session variables, ... every request from the site domain 'hangs up' from this ... Did you try asking your hosting provider? ...
    (comp.lang.php)
  • Re: session hang problem
    ... PHP 5.x.x you don't need to. ... When I have a problem like this which seems to be host related, the first people I talk to is the hosting company. ... store variables and objects inside session variables, ... every request from the site domain 'hangs up' from this ...
    (comp.lang.php)
  • Re: Using AJAX, how can the page get state infomation from backgroud PHP script?
    ... Have your original PHP store it's "status" information in a Session ... Have a timer on the Javascript side which creates a 2nd Ajax call ... If we send more than one request ...
    (comp.lang.php)
  • Re: Using AJAX, how can the page get state infomation from backgroud PHP script?
    ... Have your original PHP store it's "status" information in a Session ... Have a timer on the Javascript side which creates a 2nd Ajax call ... If we send more than one request ...
    (comp.lang.php)
  • Re: session Objects
    ... When a browser hits your site, session starts. ... I don't know about JSP, but in the PHP world, the page is only sent to ... What is usually done in PHP is to check on the *next* request whether ...
    (comp.lang.java.programmer)