Well, I modified your code slightly - Commented out the include at the top of the page and changed the location to test.php (Where I pasted your code) and it still works fine. Here is the content of the test.php page:
<?php
//include('insert.php');
if (isset($_COOKIE['shoot'])) {
$_SESSION['action'] = "reward";
}
echo "<br />Session: ".$_SESSION['action'];
echo "<br />Cookie: ".$_COOKIE['shoot'];
if($_SESSION['action'] == "reward") {
// Show rewards
$sql = mysql_query("SELECT * FROM `game_shoot` WHERE `name` = '".$_COOKIE['dwtcg']['u']."' AND date ='".date("y-m-d")."'") or die(mysql_error()); $result = mysql_num_rows($sql);
if ($result != 0) {
die("<p>Already played in this round</p></div></div></body></html>");
} else {
echo "<br/>All thats below have been added<br />";
special(); special(); character(); scene(); puzzle(); normal(); normal();
if($_COOKIE['dwtcg']['u'] != 'Obi-Wan') {
mysql_query("UPDATE `memberlist` set `credits` = (`credits` + 25) WHERE `name`='".$_COOKIE['dwtcg']['u']."' LIMIT 1") or die(mysql_error());
echo "<p>25 Credits added to account<br />";
}
mysql_query("INSERT INTO `game_shoot` VALUES (NULL, 'shoot', '".$_COOKIE['dwtcg']['u']."', '" . $_SESSION['id'] . "')") or die(mysql_error());
}
} else {
//Show images and form
?></p>
<p>Oh dear, after being chased by a bounty hunter he's managed to catch you<br />
You need to shoot him before he shoots you. To shoot him first, you must be quicker than .3 of a second</p>
<p>Once you've pressed Start, after a random amount of time the background goes black. As soon as you see it go black you must press stop</p>
<script type="text/javascript">
<!--
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
var startTime=new Date();
var endTime=new Date();
var startPressed=false;
var bgChangeStarted=false;
var maxWait=20;
var timerID;
function startTest()
{
document.body.style.backgroundColor="#000000";
bgChangeStarted=true;
startTime=new Date();
}
function stopTest()
{
if(bgChangeStarted)
{
endTime=new Date();
var responseTime=(endTime.getTime()-startTime.getTime())/1000;
document.body.style.backgroundColor="#990000";
alert("You reaction time is " + responseTime + " seconds ");
startPressed=false;
bgChangeStarted=false;
if (responseTime <= 0.60)
{
setCookie("shoot","true",1)
window.location = "test.php"
}
}
else
{
if (!startPressed)
{
alert("Press 'Start' to commence testing!");
}
else
{
clearTimeout(timerID);
startPressed=false;
alert("OI!! No cheating! Press 'start' again...");
}
}
}
var randMULTIPLIER=0x015a4e35;
var randINCREMENT=1;
var today=new Date();
var randSeed=today.getSeconds();
function randNumber()
{
randSeed = (randMULTIPLIER * randSeed + randINCREMENT) % (1 << 31);
return((randSeed >> 15) & 0x7fff) / 32767;
}
function startit()
{
if(startPressed)
{alert("Already started. Press stop to stop");
return;
}
else
{
startPressed=true;
timerID=setTimeout('startTest()', 6000*randNumber());
}
}
// -->
</script>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td><form name="response" action="">
<input onclick="startit()" type="button" value="Start" />
<input onclick="stopTest()" type="button" value="Stop" />
</form></td>
</tr>
</table>
<?php } ?>
When I run it, click the start button and then click the stop button when it goes black, I get an alert box telling me my reaction time and after clicking OK I get:
Session: reward
Cookie: trueNo database selected
which tells me that the cookie setting worked and that insert.php has some MySQL setup code 😉. Note that I delete the cookie before starting each test.
Can you just try it the way I have done and see if it works or not? Also check the cookies.txt file and see if anything changes. Maybe you have too many cookies for your site or too mach data? I don't know what the max number is or max size though.