PHP –– Cookies
written by: admin
10/29/08 Last Updated:
setcookie("Test", $value, time()+3600);
The above will create a cookie called Test
that will expire in one hour. The value can be set to the variable $cookie with the following
$cookie = $_COOKIE["Test"];
A cookie is stored on user's browser to remember small facts. It is handy for keeping a person logged in so as to avoid logging in everytime a browser is opened.
Cookies are often greatly limited in number per site and user and size whereas sessions are not. Sessions can be given expiration dates by changing the behavior in the php.ini file.
See: Difference between Session and Cookies