For those of you like me who found this v.difficult to understand here is simple version which creates and kills a cookie
?
// ===================================
// ===================================
// || Cookie Example ||
// ===================================
// ===================================
if($cookieset==yes) {
// set cookie contents
setcookie("atltest",$myval,(time() + 1800));
header("Location: $PHP_SELF");
}
if($logout==yes) {
setcookie("atltest","");
echo "deleted the cookie<br><br>";
?> <a href="index.php3">Next</a> <?
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Cookie Test</title>
</head>
<body>
<?
echo "Cookie Value: ";
echo $atltest;
?>
<form action="index.php3?cookieset=yes" method="post">
ATLTest <input type="text" name="myval">
<br>
<input type="submit" name="submit" value="submit">
</form>
<br><br>
<a href="index.php3?logout=yes">Login as another person</a>
</body>
Ross wrote:
Heh, my third post in two days... I just need a lot of help or something...
Anyway, now I'm dealing with cookies. I have a script that sets some cookies based upon whether the user has any of my cookies on the hard drive already.
My setcookie call:
setcookie("visitor", $new_id, $the_time, "/", "www.domain.com", 0);
$new_id is just an integer and $the_time is a string created by gmdate();
The cookie is stored on the harddrive (I can see them in c:\windows\cookies on my machine) but when I call the very same script which does if(isset ($visitor)) it always fails.
Anyone have any ideas about this?
Thanks a bunch everyone,
Ross