Portal Home > Knowledgebase > Articles Database > Delete cookies through code


Delete cookies through code




Posted by ashras99, 06-14-2010, 06:07 PM
I like to build a button using PHP, which delete the browser cookies of the certain defined website (in code). Please tell me is that possible or not? If yes, then what will be the code or how?

Posted by KMyers, 06-14-2010, 07:24 PM
Greetings,

Posted by foobic, 06-14-2010, 07:40 PM
Is the certain defined website different to the one hosting the code? If so, it's not possible. Cookies are restricted to the domain that sets them and can't be read or written / deleted by code on any other domain.

Posted by ashras99, 06-15-2010, 06:06 AM
No certain defined website is the same one which hosting the code. I don't think logout code will work, in case deleting all the cookies of some website.

Posted by Driver01, 06-15-2010, 06:54 AM
That will work if you define which cookie you want to expire/delete as per the setcookie() instruction. If you want to only remove say the themechoice cookie and not the login cookie just set the themechoice cookie to a past date/time to trigger the browser to remove it.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Forum under attack (Views: 507)