Deleting Cookies : setcookie « Cookie Session « PHP






Deleting Cookies

 
<?php
setcookie ( "cookie_user", "test", time () + 60 * 60 * 24 * 30 );
setcookie ( "cookie_pass", md5 ( "test" ), time () + 60 * 60 * 24 * 30 );

function logout() {
  setcookie ( "cookie_user", "", time () + 60 * 60 * 24 * 30 );
  setcookie ( "cookie_pass", "", time () + 60 * 60 * 24 * 30 );
}
logout ();
echo $_COOKIE ['cookie_user'] . "<br />";
echo "You have successfully logged out.";
?>
  
  








Related examples in the same category

1.PHP 5 setcookie() Parameters
2.Assigning cookie names according to array index value
3.Cookie created
4.Setting a cookie with a domain restriction
5.Setting a cookie with a path restriction
6.Setting an expiring cookie
7.Setting cookie expiration
8.Setting the cookie domain
9.Setting the cookie path
10.Setting the cookie path to a specific directory
11.Deleting a Cookie Using setcookie()
12.The cookie expires one day from now
13.Starting a page with setcookie()
14.Reading Cookies