asp.netvb.netcookiesexpired-cookies

Issue Deleting Cookies with Domain specified


I am setting a message cookie when users logout from a sub-domain (pm.skor.in), and then redirecting to the main domain (skor.in).

On getting to skor.in, the cookie is displayed to the user thanking them for logging out.

The issue I am having is that the cookie never goes away.

Here's the code:

If Request.Cookies("msg") IsNot Nothing AndAlso Request.Cookies("msg").Value.Length > 0 Then
    Response.Write("<div class=""notification msginfo"">")
    Response.Write("<a class=""close""></a>")
    Response.Write("<p>" & Request.Cookies("msg").Value & "</p>")
    Response.Write("</div>")
    Response.Cookies("msg").Value = String.Empty
    Response.Cookies("msg").Domain = ".skor.in"
    Response.Cookies("msg").Expires = DateAdd(DateInterval.Year, -1, Date.Now)
End If

As you can see, I am setting the cookie's value to be blank, as well as making it expire yesterday, yet whenever I navigate to another page on skor.in, the message appears, and checking the browser cookies, it still exists.


Solution

  • Sorry. I'm a tool.

    The issue was that I was not setting the domain on logging out.

    thanks anyways