Clearing 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
jslick
Forum Commoner
Posts: 35
Joined: Wed Jul 21, 2004 11:18 am

Clearing cookies

Post by jslick »

Is there a way to clear all cookies from the website using PHP? Another question (little off topic): I have an auto-increment in a table, how do I reset that (bring down to 1 or 0) with MySQL AND phpMyAdmin?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Does print_r($_COOKIE) print all cookies, or just ones related to the domain? If it outputs all the user's cookies, I suppose you can cycle through $_COOKIE array and unset them all..something like this

Code: Select all

foreach ($_COOKIE as $cookie_val) {
setcookie ($cookie_val, "", time() - 3600); }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

note: the cookie has to match on the path and domain used in the original cookie.. at least last I had to play with deleting cookies..

As for resetting the auto_increment, you can do it in the "operations" pane in phpmyadmin of that table.
jslick
Forum Commoner
Posts: 35
Joined: Wed Jul 21, 2004 11:18 am

Post by jslick »

thanks feyd, I found the auto-increment thing.
Post Reply