Ive got a Flash movie. It has 9 movie clips. Each movie clip contains a Photo of a Girl with 3 possible choices to rate (Hot, OK, Yuck!). When the user votes on a girl, I want to set a cookie (one cookie for each of the 9 movie clips)via the same php script I am calling when the user clicks a choice button:
on (release) {
loadVariables("vote.php", this, "POST");
-----------------------------------------------------------
at the moment, I have it set up so that only one cookie gets set no matter which poll is voted on. and if the user only votes on one poll then leaves; when they return then all polls show the results and the user can't vote anymore. This is not cool or optimal...and I really need some help to sort this out.
Heres the snip of PHP that I am using to set my cookie:
// Set cookie so user can't vote again
setcookie('hasVoted', 'yes', time() + (365 * 86400), "/");
}
-----------------------------------------------------------------
Now, when the movie loads...an onClipEvent handler is being used to call fetchPoll.php
This is the bit of code that brings in the cookies....
// If cookie says user has voted before...
if('yes' == $HTTP_COOKIE_VARS['hasVoted']) {
// Tell Flash movie
print "&result=AlreadyVoted";
} else {
// Otherwise return okay
print "&result=Okay";
}
--------------------------------------------------------------------
NOw for my confusion. Or....here is where you can hopefully help me learn....
1. How do I make this work with setting one cookie per poll as opposed to one cookie for the whole movie?
2. How do I bring these multiple cookies back into Flash, check to see if a cookie has been set for each poll, and then do the appropriate action? (if cookie set=show results; but if cookie is not set=let user vote)
For a visual of whats going on, check here:
http://tst.iserve.ch/babes/babevote2.html3. Can I set a variable in PHP like $myCookies = $HTTP_COOKIE_VARS
and then echo it back to Flash with: &myCookieArray = $myCookies; or am I on the wrong track??
4. Once I get the variables back into Flash....how do I check to see if a cookie has been set for each poll? Should I use something like:
if (
myCookie Array[1] = hasVoted, poll_1.showResults;
??
Please help if you can...Im stumped and really want to learn this! By the way if this works out i will open the source files to whoever may be interested too.
Thanks for any efforts
John Lyons