Setting a cookie:

<?php
setcookie( "visit", "art", time()+3600, "/", $SERVER_NAME, 0);
?>

Printing a cookie:

Hello you. This may be your first visit

PHP code:
if ( isset( $visit ) )
print "<p>'Hello again, you visited this site for $visit</p>";
else
print "<p>Hello you. This may be your first visit</p>";

Deleting a cookie

To delete a cookie you call setcookie() with the name argument only:
setcookie("mycookie");
The safer way is to set a cookie with the date that has already expired:
setcookie( "visit", "art", time()-3600, "/", $SERVER_NAME, 0);





Back to main page