$name: cookie name, optional
$value: cookie value, optional
$expire: time for the cookie to expire, in seconds, optional
$path: path the cookie will work. if "/", it works on the whole domain, optional
$domain: domain the cookie will work. "perschon.com" works for all like "https://convert.idontcarewhatyouthink.net" and "tutorial.perschon.com", optional
$secure: worked only over a secure HTTPS protocol, default is FALSE, optional
$httponly: work only over a HTTP protocol, default is FALSE, optional
<?PHP setcookie("login","mike");//set cookie "login" with value "mike" setcookie("login","mike", time()+3600);//expire after 1 hour setcookie("login","mike", time()+3600,"/program/","perschon.com");//expire after 1 hour echo "$_COOKIE["login"]";//show cookie value ?>
To delete cookie, set its expiration time to the past:
<?PHP setcookie("login","mike", time()-60);//expired 1 minute ago ?>