set the expiration date for a specific domain

169 views Asked by At

I ran across a small problem with deleting a cookie.

I'm in the domain my.domain.net

I have a cookie (not an HTTP cookie) with an expiration of 15 days. The cookie's domain is in my.domain.com and I need to delete that cookie so I'm doing the following:

document.cookie = '.ASPXAUTH=;expire=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=my.domain.net';

The thing is that it creates another cookie with the same name BUT under the domain: .my.domain.net I assume that is the reason I can't delete that cookie.

Am I doing something wrong?

1

There are 1 answers

0
Ace On

After a little investigation, I found the answer: I just don't need to set the domain for that cookie i.e.:

document.cookie = '.ASPXAUTH=;expire=Thu, 01 Jan 1970 00:00:00 GMT;path=/';