I have set the two following cookie when a user successfully logs in.
$total = mysql_query("SELECT total FROM usersystem WHERE username = '$username'");
setcookie("username", "$username", time()+3600);
setcookie("total", "$total", time()+3600);
header( 'Location: play.php' ) ;
$_SESSION['username'] = $username;
(Username is previously defined and does display when retrieved.)
Then on the page I want to retrieve the information I have the following code:
<?php
include("db.php");
echo $_COOKIE["username"] ;
echo $_COOKIE["total"];
if ((isset($_COOKIE["username"])) && (isset ($_COOKIE["total"]))) {
echo "Welcome " . $_COOKIE["username"] . "!";
echo "Score: " . $_COOKIE["total"]; }
else {
ob_start();
header( 'Location: nogo.php' ) ;
}
?>
Again, username displays correctly and if the cookie is not set, it does redirect to nogo.php. However, where the total should display it simply displays: Resource id #3
Any help where I am going wrong?