deleting the damn cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

deleting the damn cookies

Post by cheatboy00 »

now i'm having more problems with those pesky cookies.... anyway i'm creating a logout page which should be easy but my incompetence amazes me ... anyway i duno whats wrong with this it wont update the online file to n like i want and it wont delete the cookies

Code: Select all

if (isset($idcbaa)){

   $dbh = mysql_connect ("localhost", "dragonsb_xmb1", "password") or die ('I cannot connect to the database.');
      mysql_select_db ("dragonsb_xmb1");
	
   mysql_query("UPDATE users SET online='n' WHERE id='$idcbaa'");
}

setcookie ("idcbaa","",time()-3600,"/","cbaa.vze.com");
setcookie ("logcbaa","",time()-3600,"/","cbaa.vze.com");
arg
Elfstone
Forum Newbie
Posts: 21
Joined: Tue Jun 11, 2002 2:25 am
Location: NJ, USA

Post by Elfstone »

To delete a cooke just use:

Code: Select all

setcookie ("cookiename");
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

Post by cheatboy00 »

it worked thanks
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

You MUST delete a cookie with all of the same parameters as it was created, so if you include domains etc when the cookie was created they must also appear when you want to delete the cookie.
Post Reply