I am working on a project which needs to update cookies very frequently. I tried overwrite previous cookie with a new one has the same key, but failed. Then I tried "delete" outdated cookies by re-Set-Cookie a same cookie with expires on tail whose value is the time request arrives, failed again.
Wiki says : With an expiration time in the past, the browser will delete this cookie right away – note that cookie will only be deleted when the domain and path attributes in the Set-Cookie
header match the values used when the cookie was created .
MSDN says : You cannot directly delete a cookie on a user's computer. However, you can direct the user's browser to delete the cookie by setting the cookie's expiration date to a past date. The next time a user makes a request to a page within the domain or path that set the cookie , the browser will determine that the cookie has expired and remove it.
So the point is Path and Domain have to match, then browsers WILL clear outdated cookies.
本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议 进行许可。