To set a cookie,
PHP Code:
if ($HTTP_HOST != $SERVER_NAME) { // If no 'WWW', Cookie won't work in Netscape
header ("Location: http://www.$HTTP_HOST$SCRIPT_NAME?$QUERY_STRING");
exit;
}
setcookie ("cookiename", cookievariable, time()+31536000, "/", ".$HTTP_HOST", 0); // Sets a Cookie which will Expire in a Year's time
to read a cookie, just read it by accessing the cookiename variable.
like..
PHP Code:
// To check if cookie exists
if ($cookiename) { echo 'Cookie Exists'; }
else { echo 'Cookie does not Exist'; }
Bookmarks