6

I am using following code to delete a cookie:

document.cookie = "CookieName=; expires=Thu, 01 Jan 1970 00:00:00 UTC";

There are two cookies, one in on domain www.websiteaddress.com and other is on .websiteaddress.com. When I am on page www.websiteaddress.com the cookie having domain address www.websiteaddress.com gets deleted but other one is not deleted. How can I delete both cookies while loading javascript on www.websiteaddress.com

1 Answer 1

5

You are not allowed to delete cookies on another site. Because there is no guarantee that you own both www.websiteaddress.com and .websiteaddress.com. You can only delete cookies that you set for the current domain.

Sign up to request clarification or add additional context in comments.

2 Comments

Both cookies are on same domain but the address used to save them is different. One is with www and other one is without www.
you won't be alllowed to delete the cookies of .websiteaddress.com from www.websiteaddress.com.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.