note 94431 modified in function.setcookie by danbrown

From: Date: Thu, 14 Jan 2010 01:33:07 +0000
Subject: note 94431 modified in function.setcookie by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164954@lists.php.net to get a copy of this message
By deleting cookies you should think server side too. In this example: <?php // set the expiration date to one hour ago setcookie ("TestCookie", "", time() - 3600); setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1); ?> deletes just client side cookies. You should use bellow example to delete both client and server side cookies: <?php // set the expiration date to one hour ago setcookie ("TestCookie", "", time() - 3600); unset($_COOKIE['TestCookie']); // or setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1); unset($_COOKIE['TestCookie']; ?> --was-- By deleting cookies you should think server side too. In this example: <?php // set the expiration date to one hour ago setcookie ("TestCookie", "", time() - 3600); setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1); ?> deletes just client side cookies. You should use bellow example to delete both client and server side cookies: <?php // set the expiration date to one hour ago setcookie ("TestCookie", "", time() - 3600); unset($_COOKIE['TestCookie']; // or setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1); unset($_COOKIE['TestCookie']; ?> http://php.net/manual/en/function.setcookie.php

« previous php.notes (#164954) next »