Bruce Gust
asked on
Flash cookie in PHP
I need a tutorial on how to grab a Flash cookie and store it in a MySQL database. I've been looking on google, but I haven't found anything yet.
Any help would be most appreciated.
Bottom line: I have to grab the Flash cookie, store it in a database and then when that same user logs in, I need to see how many times they've logged in previously. I have my code attached. I need to implement the Flash cookie into the mix and replace the traditional cookie as I currently have it scripted.
Any help would be most appreciated.
Bottom line: I have to grab the Flash cookie, store it in a database and then when that same user logs in, I need to see how many times they've logged in previously. I have my code attached. I need to implement the Flash cookie into the mix and replace the traditional cookie as I currently have it scripted.
<?php
//purge the table of any dates unlike today
$today = date("Y-m-d");
$redsox = "select * from songwriting_login where ballot_date<>'$today'";
$redsox_query = mysqli_query($cxn, $redsox)
or die("Couldn't execute query.");
$redsox_row = mysqli_num_rows($redsox_query);
if($redsox_row>0)
{
$titans = "delete from songwriting_login where ballot_date <>$today";
$titans_result = mysqli_query($cxn, $titans);
if(!$titans_result){
$error = mysqli_errno($cxn).': '.mysqli_error($cxn);
die($error);
}
}
//check to see if the user's cookie is set. If it is, then we see if it's in the database
if(!empty($_COOKIE['showdown_user']))
{
$oatmeal = "select oatmeal_raisin from songwriting_login where oatmeal_raisin='" . $_COOKIE['showdown_user'] . "'";
$oatmeal_query = mysqli_query($cxn, $oatmeal)
or die("Couldn't execute query.");
$oatmeal_count = mysqli_num_rows($oatmeal_query);
if($oatmeal_count>4)
{
//the user's cookie is in the database 5 times which means that they're getting ready to exceed the maximum number of logins
header("Location: songwriting_too_many_logins.php?email=$voter_email");
exit();
}
else
{
$insert = "insert into songwriting_login (ballot_date,oatmeal_raisin)
values ('$today','" . $_COOKIE['showdown_user'] . "')";
$insertexe = mysqli_query($cxn, $insert);
if(!$insertexe) {
$error = mysqli_errno($cxn).': '.mysqli_error($cxn);
die($error);
}
$login_count = 5 - ($oatmeal_count+1);
}
}
else
{
//there isn't any showdown_user cookie on the voter's computer so we set one up and insert it into the database
$random = (rand()%1000000);
setcookie("showdown_user", "$random");
$insert = "insert into songwriting_login (ballot_date,oatmeal_raisin)
values ('$today', '$random')";
$insertexe = mysqli_query($cxn, $insert);
if(!$insertexe) {
$error = mysqli_errno($cxn).': '.mysqli_error($cxn);
die($error);
}
$login_count = 4;
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The dilemma isn't resolved, but I'm going to go ahead and interpret that as being an indicator that what I'm trying to do either isn't possible or it isn't common.
Thanks for the points! You may want to reissue the question but use "LSO files" or "LSO" to describe the "flash cookie".
ASKER
http://www.wired.com/epicenter/2009/08/you-deleted-your-cookies-think-again/