I have created cookie using document.cookie in a jsp page.
In my servlet (remember its not a jsp page where I can use java script. Its a servlet), I am retrieving cookie value and after its use, I want to delete them. I dont want to delete the cookies by using expiry time. I want to clear off its values. So, I am doing cookie.setValue("");
But, when I check the cookie in my Browser, its still holding the value. Its not clearing off.
- How to clear off its value?
- Also, is there a way to clear off the cookie name? I know that there is no cookie.setName() function. So, any other means?
After clearing, basically I dont want a user to see the cookies in the browser.
Regards,
You can delete cookie in 2 ways, either in your Servlet (as a server-side code), or if your Servlet renders an HTML document, you may add an page onload event as javascript code.
// Server-side Code
For the client-side cookie deletion, you may check this http://www.webdevelopmentcentral.net/2007/12/client-side-cookie-handling.html