Delete Cookies

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snowwwolf
    New Member
    • Jan 2007
    • 28

    #1

    Delete Cookies

    How Can I delete the cookies.

    I wrote like that

    Response.Cookie s.Remove("passw ord");

    but, it did not work.

    I use ASP.NET 1.1 with C#
    <X>
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    If you want to delete the cookie on the client machine, do not use the obvious Response.Cookie s.Remove("MyCoo kie") which simply tells the cookie not to overwrite the client's cookie (see below for a more detailed explanation), set the cookie's Expires property to any time prior to the current time. This will tell the client to overwrite the current cookie with an expired cookie and the client will never send it back to the server.

    The safest (and most symmetric) way to delete the cookie by using an Expiry date of DateTime.Now.Ad dYears(-30)...

    Hope that this helps.

    Comment

    • snowwwolf
      New Member
      • Jan 2007
      • 28

      #3
      Originally posted by kenobewan
      If you want to delete the cookie on the client machine, do not use the obvious Response.Cookie s.Remove("MyCoo kie") which simply tells the cookie not to overwrite the client's cookie (see below for a more detailed explanation), set the cookie's Expires property to any time prior to the current time. This will tell the client to overwrite the current cookie with an expired cookie and the client will never send it back to the server.

      The safest (and most symmetric) way to delete the cookie by using an Expiry date of DateTime.Now.Ad dYears(-30)...

      Hope that this helps.

      yes, i got it, thanks for your replay!

      Comment

      Working...