Hello, I've been trying to find some informations on Google but I couldn't find anything that can solve my problem! I need to find a way to clear cookies of the user everytime he loads my page. If anyone knows a way, please share it. I posted this in JavaScript section as I heard that this can only be done using JS. Thanks in advance. Regards, Radu
You need to use SetCookie function of Javascript and make sure that you dont set the expires attribute so that it will be deleted once after he closes the browser. Let me know if this solves your problem
not tested - found this on some site. the idea is sound - i don't think there is a way to do document.cookie = ""; - you need to loop through them all function deleteAllCookies() { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; } } PHP: it may probably be easier in php: foreach($_COOKIE as $key => $value) unset($_COOKIE[$key]); PHP:
that's right, you can use JavaScript to do these things, you should use these code: - Delete those cookies - Delicious Cookies - the complete Cookie manual with JavaScript - and more Cookie with JavaScript codes