Using cookies in php - PHP Views : 373
Tagged in : PHP
0 0
Send mail
Cookies allow the webmaster to store information about the site visitor on their computer to be accessed again the next time they visit. One common use of cookies is to store your username and password on your computer so you don't need to login again each time you visit a website.

Create a Cookie?

Syntax:

setcookie(name, value, expire, path, domain);


Example:

<?php
setcookie("user", "cookie value", time()+3600);
?>


Retrieve cookie value

Example:

echo $_COOKIE['user'];


Delete a Cookie
To delete a cookie set the expiration date to the past date.

Example:


<?php
setcookie("user", "", time()-3600);
?>
By Rekha, On - 2009-10-29



    Login to add Comments .