Problem with deleting cookies

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Problem with deleting cookies

    Hello,

    I have problem deleting cookies and cookies values (using framework version
    1.1 on W2003).

    When I try to remove entire cookie, by calling
    Response.Cookies.Remove("Test"), nothing happens, the cookie "Test" remains
    unchanged.

    When I try to remove one of cookie values, by calling
    Response.Cookies("Test").Values.Remove(Key), all values are cleared (but
    cookie itself remains), regardless what is used as Key - existing value
    name, non-existent value name, empty string.

    It seems to me as error in framework, because documentation says that it
    should work. Or it's problem between keyboard and chair?

    --
    Michal A. Valasek, Altair Communications, [url]http://www.altaircom.net[/url]
    Please do not reply to this e-mail, for contact see [url]http://www.rider.cz[/url]


    Michal A. Valasek Guest

  2. Similar Questions and Discussions

    1. problem with cookies...
      hi i do a survey in php i would like to allow only one vote but i don't know why, i can vote 2 times... the survey display with this...
    2. HTTPWebRequest + Cookies problem
      Hi, In continue to another post which I have in this news group, I was able to find out some more details about the problem What is my...
    3. Problem with Forms Authentication cookies
      Hi, We're having an issue with Forms Authentication cookies being treated as expired / invalid, and being deleted. This is causing our intranet...
    4. problem with LWP Cookies
      Hello , I have been trying to use LWP to access a secured page. Its a 2 step process where initially I need to authenticate myself and the...
    5. #14389 [Com]: cookies problem
      ID: 14389 Comment by: php at shop4host dot net Reported By: demon at dreamers dot gr Status: Closed Bug Type: ...
  3. #2

    Default Re: Problem with deleting cookies

    No bug with the Framework, although as you have learned the Remove method is
    a bit confusing to have for the Cookie collection. (Maybe this is because
    the cookie collection inherits from some other collection and yes, I'm too
    lazy to look :-).

    Anyway, the solution to your problem is to set the expiration date of the
    cookie to some value in the past. Actually once you create a cookie, you
    can't access it's expiration date despite it being a read/write property in
    the framework. This is due to the official/Non-Microsoft (Netscape/w3c)
    cookie specification.

    So if you are not confused at this point, the true solution is to create
    another cookie in ASP.Net that has the same cookie name as the one you want
    to delete and specify an expiration date to some value in the past. The idea
    is the old cookie will be replaced by the new one. Alternatively, don't
    specify an expiration date is effectively the same thing. Both will delete
    the cookie at the end of the user's session.

    Hope this helps.
    --
    Peter O'Reilly
    "Michal A. Valasek" <news@altaircom.net> wrote in message
    news:Oeff2IrUDHA.1812@TK2MSFTNGP11.phx.gbl...
    > Hello,
    >
    > I have problem deleting cookies and cookies values (using framework
    version
    > 1.1 on W2003).
    >
    > When I try to remove entire cookie, by calling
    > Response.Cookies.Remove("Test"), nothing happens, the cookie "Test"
    remains
    > unchanged.
    >
    > When I try to remove one of cookie values, by calling
    > Response.Cookies("Test").Values.Remove(Key), all values are cleared (but
    > cookie itself remains), regardless what is used as Key - existing value
    > name, non-existent value name, empty string.
    >
    > It seems to me as error in framework, because documentation says that it
    > should work. Or it's problem between keyboard and chair?
    >
    > --
    > Michal A. Valasek, Altair Communications, [url]http://www.altaircom.net[/url]
    > Please do not reply to this e-mail, for contact see [url]http://www.rider.cz[/url]
    >
    >

    Peter O'Reilly Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139