radiohomer Posted May 10, 2011 Share Posted May 10, 2011 hey guys i have a script that creates a cookie named "MyLoginPage" now everything works well the cookie is saved and it keeps the user logged in The Question ok so im wanting to create a link that will delete the cookie so when the user clicks the link it will delete the cookie is this possible?? if so, how?? many thanks Link to comment https://forums.phpfreaks.com/topic/236017-quick-question/ Share on other sites More sharing options...
ilovephp Posted May 11, 2011 Share Posted May 11, 2011 yes its possible... create a link add href wil be the file name which will delete that cookie <a href="del_cookie.php">Click here to delete cookie</a> and your del_cookie.php file will contain below code <?php setcookie("user", "", time()-3600); ?> Simple logic to delete cookie is just assign past time to the cookie Link to comment https://forums.phpfreaks.com/topic/236017-quick-question/#findComment-1213656 Share on other sites More sharing options...
radiohomer Posted May 11, 2011 Author Share Posted May 11, 2011 yes its possible... create a link add href wil be the file name which will delete that cookie <a href="del_cookie.php">Click here to delete cookie</a> and your del_cookie.php file will contain below code <?php setcookie("user", "", time()-3600); ?> Simple logic to delete cookie is just assign past time to the cookie thank you ilovephp i would also like to thank Paul for his comment below sent via PM this helped A LOT and is now working make a link to a page logout.php - logout.php <? if(setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )){ echo 'All done'; }else{ echo 'Failed to log you out because you are most likely your not logged in.'; } ?> And read http://php.net/manual/en/function.setcookie.php Link to comment https://forums.phpfreaks.com/topic/236017-quick-question/#findComment-1213701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.