-
I got cookies to write to the users hard drive but Im having problems bringing the values of the cookie variables into flash, I have a forum I made in flash using php and I would like to get the username and password to load automatically through cookies like normal forums (this one included), its just I cant for some reason bring them into flash without causing any errors, if any one knows how to do it or what php script i should use to get the variables and values of the cookies and how to bring that into flash Id appreciate it very much
Thanks in advance for any help
Deadsam
-
Hi,
replace the object / embed stuff with javascript code that extracts the cookie value
<script>
cook = document.cookie;
while(l = cook.indexOf(";")) > 0)
cook = cook.substr(0, l) + '&' + cook.substr(l+2);
document.write('<object.....>'+
'<param name=movie value="movie.swf?cook='+cook+'">'+
....
'<embed src="movie.swf?cook='+cook+'" width=.....></embed>'+
'</object>')
</script>
Musicman
-
Thanks I didnt know I could use javascript to read the php script to get the cookies into flash, I dont have a clue how to do this but if its the best way I'll learn how.
Isnt there a way to do it example:
heres my php script i wrote to read the cookies
//setup cookies
setcookie('username', '$username',$time,"/","www.deadsam.com",0);
setcookie('password', '$password',$time,"/","www.deadsam.com",0);
//get number of set cookies
$cookieCount = count($HTTP_COOKIE_VARS);
//if more than 1 cookie
if ($cookieCount > 0) {
//Loop through all the cookies...
foreach($HTTP_COOKIE_VARS as $cookiename => $cookieValue){
//output name and value
print "$cookiename=$cookieValue&";
}
} else {
//otherwise out no cookies
print "&userStatus=you are not logged in";
}
then in flash put
loadVariables("http://www.deadsam.com/cookies.php", this, "GET");
so it reads the variables and brings it into flash?
I tried this by the way , it does work but I get errors.
If there is now way to do it just using php I'll learn the javascript way of doing it :)
Thanks for any and all help
Deadsam
-
Watch your practise of counting all HTTP_COOKIE_VARS, that will count every cookie on your computer!!!
So: if you have a cookie from another site, $cookieCount would be 1, and the if/else would be useless..
Here's a quick cookie example:
Code:
<?php
setcookie("username", "NuCleuZ");
setcookie("password", "MacOSX");
echo "username=" . $HTTP_COOKIE_VARS['username'];
echo "&password=" . $HTTP_COOKIE_VARS['password'];
echo "&status=finished";
?>
-
thanks I'll try it out :)
Deadsam