Cookies are used to store information in browser itself.
Server used to send information to clients browser. Then browser store all those details in small text files in users computer.
Cookies used to set in HTTP header.
HTTP header set cookie with name, expire date, domain name and path.
In php we can access the cookies using environment variable $_COOKIE
Setting cookie with php
Using “setcookie()” function we can set the cookie.
Setting cookie for 1 day: we need to specify the time of cookie expiration in seconds.
Accessing cookie with php
Using global variable $_COOKIE we can access cookies.
<?php echo $_COOKIE[“id”]; ?>
Deleting cookie with php
Using “setcookie()” function we can also delete the cookie. But we need to set time that already expired.
setcookie( “id”, “”, time()- 60);
More about sessions: Sessions