LaRoza Posted May 1, 2007 Share Posted May 1, 2007 I am having trouble with cookies. I can set the cookie and read it value, but I can not delete it. Could anyone tell me the proper way to delete a cookie, this cookie in particular: setcookie('created','1',time()+3600); Thank you! Link to comment https://forums.phpfreaks.com/topic/49464-solved-php-cookies/ Share on other sites More sharing options...
taith Posted May 1, 2007 Share Posted May 1, 2007 <? function destroycookie($name){ setcookie("$name", "", time()-3600); } destroycookie('created'); ?> Link to comment https://forums.phpfreaks.com/topic/49464-solved-php-cookies/#findComment-242424 Share on other sites More sharing options...
LaRoza Posted May 1, 2007 Author Share Posted May 1, 2007 Does it have to be on the same page on which the cookie is set? I can use the function if it is only on the same page; however, it fails to delete it if it is on another. Link to comment https://forums.phpfreaks.com/topic/49464-solved-php-cookies/#findComment-242449 Share on other sites More sharing options...
taith Posted May 1, 2007 Share Posted May 1, 2007 it shouldnt matter which page your removing the cookie from... as long as you have access to the function... or just use the bare essentials from it... setcookie('created', "", time()-3600); that works just as well... basically your just setting a blank cookie overtop of the old one, that expired an hour ago(immediatly)... Link to comment https://forums.phpfreaks.com/topic/49464-solved-php-cookies/#findComment-242575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.