New Coder Posted December 1, 2008 Share Posted December 1, 2008 Hello all, I hope someone can help because I'm lost... How do I delete a cookie that was created in a sub directory? For insatnce I have www.mysite.co.uk/main_detail.php a user navigates to www.mysite.co.uk/subdirectory/detail.php where a cookie is created. If they click on a link that returns them to www.mysite.co.uk/main_detail.php how do I delete the cookie creted on the sub directories page?? I have tried setcookie("detail_cookie",$detail_cookie, time()-60); on the main_detail.php page but it doesn't work. I hope this made sense. Many Thanks Link to comment https://forums.phpfreaks.com/topic/134980-solved-delete-cookie-from-sub-directory/ Share on other sites More sharing options...
JonnoTheDev Posted December 1, 2008 Share Posted December 1, 2008 You need to specify the cookie path in the set_cookie() path parameter // set setcookie("test", $value, time()+3600, "/mysubdir/"); // destroy setcookie ("test", "", time() - 3600, "/mysubdir/"); If you set the path to / it will be available within the entire domain setcookie("test", $value, time()+3600, "/"); Link to comment https://forums.phpfreaks.com/topic/134980-solved-delete-cookie-from-sub-directory/#findComment-703079 Share on other sites More sharing options...
New Coder Posted December 9, 2008 Author Share Posted December 9, 2008 That worked a treat. Many Thanks Link to comment https://forums.phpfreaks.com/topic/134980-solved-delete-cookie-from-sub-directory/#findComment-710424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.