-
Reading PHP Session Variable
Hey all,
I'm just trying to do a scene change in flash depending on the existence of a PHP session variable. How does Actionscript read PHP session vars?
-
Registered User
hi,
You'll need to have a PHP script grabbing all the information you want from the Session. This script outputs the information as a variable sessionInfo for example.
Like this, Flash can load that variable from the PHP script using the LoadVars Class.
code:
// set a LaodVars Object to load and preload the data
var my_lv:LoadVars = new LoadVars();
// when the data finishes loading
my_lv.onLoad = function(ok:Boolean)
{
if (ok)
{
trace(this.sessionInfo);
}
else
{
trace("error");
}
}
my_lv.load("script.php");
Last edited by nunomira; 04-17-2007 at 09:12 PM.
-
Hi there I am having a similar problem:
When trying to access my flashdata.php file from within my Flash Movie, my Flash Movie receives a different session ID than the logged in user, and so my session variables do not contain any data.
How can I pass the session ID of the logged in user to the Flash Movie so that it can obtain the relevant session variables?
Thank you!
-
Registered User
hi,
If the user has already logged in outside Flash, a session variable already exists and you can pass it to Flash via FlashVars. You can then use it, if needed, by appending it to the url.
If the user logs in from Flash, I can't see how this is possible... That would mean that a new session variable is created each time you make a new call, which doesn't make much sense (although such thing exists, as a means to prevent session hijacking).
-
Thanks for your quick reply.
The users do not log in through flash, hence the difference in session id's.
How would I go about using FlashVars to send the session ID to Flash? (I am somewhat of a newb at ActionScript).
Thank you.
-
Registered User
hi,
In the documentation for SWFObject, there's an example under "How do you use JavaScript Objects to define your flashvars, params and object's attributes?".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|