How to Delete Cookies


Cookies can be deleted by specifying their expiration date.


You cannot directly delete a cookie on a user's computer. To remove a cookie, you must set the cookie's expiration date and time to a time in the past. The browser will then remove the cookie the next time a request is made and the cookie is inspected.

dim cookieName as c
cookieName = "CustomCookie"
if Context.Request.HasCookie(cookieName) then
    dim cookie as System::Web::HttpCookie = Context.Request.GetCookie(cookieName)
    cookie.HttpOnly = .t.
    cookie.Expires = ctodt("1/1/1970 12:00:00 00 am")
end if

The expiration time is the time on the client that the cookie expires.

See Also