Cookies is used to Store Data in Remote Browsers.
Cookies helps to Track Users with their Different and Unique identity.
You can set cookies using the setcookie() or setrawcookie() function.
setcookies() is called before Result has been sent to Browser.
Cookies sent by any Site will be stored into $_COOKIES of your Browser.
Cookies are unique for Each browsers.
Depending on register_globals, regular PHP variables can be created from cookies.
Cookies are text files stored on the client computer and they are kept of use tracking purpose.
Server send user Details via Cookies.
Local Machine send all the Details of user into their Local Machine for further details.
Once new request is send to server it send old cookies to to identify users and its details.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Setting Cookies in PHP : Example in PHP</title> </head> <body> <?php setcookie(name, value, expire, path, domain, security); ?> <?php setcookie("MYNAME","value",time()+$int); /*MYNAME is your cookie's name value is cookie's value $int is USED TO EXPIRE cookie */ ?> Getting Cookie ============================= <?php echo $_COOKIE["your cookie name"]; ?> Updating Cookie ============================= <?php setcookie("color","red"); echo $_COOKIE["color"]; /*color is red*/ /* your codes and functions*/ setcookie("color","blue"); echo $_COOKIE["color"]; /*new color is blue*/ ?> Deleting Cookie ============================== <?php unset($_COOKIE["yourcookie"]); /*Or*/ setcookie("yourcookie","yourvalue",time()-1); /*it expired so it's deleted*/ ?> </body> </html>