
Another great feature in PHP is cookie
handling, PHP lets us do this with ease. The function we use to set a
cooke is setcookie().
setcookie('username', $name);
It's as easy as that, the first parameter is
the string name of the cookie, this cookie will now be know as
username. The second value is the value which you want to store in the
cookie, in this case it's a variable $name. The above is the bear
minimum, this is the simplest cookie you can set, and this cookie will
deleted when the user ends their session (closes their browser). We can
define how long we wish a cookie to last: