How to set Cookies in PHP?


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" "">
<html xmlns="">
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Setting Cookies in PHP : Example in PHP</title>
            setcookie(name, value, expire, path, domain, security);

            /*MYNAME is your cookie's name
            value is cookie's value
            $int is USED TO EXPIRE cookie */
        Getting Cookie
            echo $_COOKIE["your cookie name"];

        Updating Cookie
            echo $_COOKIE["color"];
            /*color is red*/
            /* your codes and functions*/
            echo $_COOKIE["color"];
            /*new color is blue*/

        Deleting Cookie
            /*it expired so it's deleted*/