troubleshooting Question

Flash cookie in PHP

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
PHPAdobe Flash
4 Comments1 Solution406 ViewsLast Modified:
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.
<?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;
}

?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros