tivrfoa Posted December 18, 2008 Share Posted December 18, 2008 hello! if I create the cookie this way: setcookie('cookieName','cookieValue',0); I can delete the cookie: setcookie('cookieName', '', mktime(12,0,0,1, 1, 1990)); but I can't delete when I specify the path: setcookie('cookieName', 'cookieValue', 0, "/"); could someone help me? what am I doing wrong? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/ Share on other sites More sharing options...
rhodesa Posted December 18, 2008 Share Posted December 18, 2008 when deleting the cookie, you must use the same path as when setting the cookie Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/#findComment-718972 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 setcookie('cookieName', '', time()-3600); That would be easier than the mktime. But the reason is you did not specify the path when creating the cookie. Try specifying the path and using this: setcookie('cookieName','cookieValue',time()+3600, "/"); // for one hour at path / setcookie('cookieName', '', time()-3600, "/"); Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/#findComment-718981 Share on other sites More sharing options...
tivrfoa Posted December 18, 2008 Author Share Posted December 18, 2008 thanks rhodesa and premiso! That would be easier than the mktime. It's because I read that although it works in most cases, there can be problems if a user's timezone is set wrongly. source: http://www.freewebmasterhelp.com/tutorials/cookies/2 Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/#findComment-718986 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 thanks rhodesa and premiso! That would be easier than the mktime. It's because I read that although it works in most cases, there can be problems if a user's timezone is set wrongly. source: http://www.freewebmasterhelp.com/tutorials/cookies/2 I could see that. You could do this to thwart that issue... setcookie('cookieName', '', time()-(3600*48), "/"); // set it to 2 days behind =) Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/#findComment-719035 Share on other sites More sharing options...
rhodesa Posted December 18, 2008 Share Posted December 18, 2008 thanks rhodesa and premiso! That would be easier than the mktime. It's because I read that although it works in most cases, there can be problems if a user's timezone is set wrongly. source: http://www.freewebmasterhelp.com/tutorials/cookies/2 I could see that. You could do this to thwart that issue... setcookie('cookieName', '', time()-(3600*48), "/"); // set it to 2 days behind =) or just set it to 1: setcookie('cookieName', '', 1 "/"); Quote Link to comment https://forums.phpfreaks.com/topic/137562-solved-delete-cookie/#findComment-719050 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.