Help with setting expiration dates on COOKIES

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

  1. #1

    Default Help with setting expiration dates on COOKIES

    This has to be a very common question, but my search did not come up with an
    answer.

    I needed to set an expiration time for a cookie. In .NET, is seems that the
    server-side code is used to set the expiration date of the cookie. More
    specifically, I've seen several examples (from the Microsoft site) where the
    cookie information, including the expiration date is set on the server. I
    wonder how this can work. If the client and server do not have the same time
    stamp, how can this work. For example, if the expiration time is 20 min and
    the client is 12 hours forward in time, as soon as the request returns to
    the client, the cookie is expired and no longer "issued".

    It seems to me that the server either needs to take into account, the
    client's time when the expiry time is set.

    I noticed that in some documentation, the expires flag is supposed to use
    GMT. But if the user plays with the date
    on their machine, the cookie may be prevented from expiring.

    What is wrong with my logic?


    Thanks
    Rick


    Rickey Tom Guest

  2. Similar Questions and Discussions

    1. Setting cookies [URGENT]
      Can anyone tell me why this code does not do what I want it to: <?php if (!isset($_COOKIE)) { setcookie("basket", $item_code,...
    2. Setting cookies using WebDatablade.
      I am having a problem passing multiple cookies from one page to the other. I am using web.4.10.UC1. With debug level of "-1", I can see the...
    3. Issue with Cookies not getting deleted even after setting a previous date in expires property
      I am using the following to delete the contents of a cookie Response.Cookies("maincookie").expires = DateAdd("d",-2,now) Response.redirect...
    4. Cookie Expiration
      Is there a way to write a cookie to the browser, then redirect.... If I do the following, the cookie is not written. Dim cookie As New...
    5. Help setting cookies without page reload.
      Hello All I'm trying to write a script that sets a cookie without having to refresh the page to read it back in. This is how I am doing it at...
  3. #2

    Default Re: Help with setting expiration dates on COOKIES

    Since the server is the one issuing the cookie and doing so on their 'clock'
    it logically makes sense that the expiration date specified is that of the
    server. In other words, the server has no knowledge of what time zone,
    date, etc. of the requesting client computer. Why should it? It's not
    necessary and having all the cookies issued timed/date stamped under one
    clock makes things a whole lot easier for the server to manage state.

    The server sends cookie information to the requesting source, the web
    browser. From there, expiration and removal of the cookie is the browser's
    responsibility. In creating the actual cookie (file) the browser may
    translate GMT to local time when creating the cookie.

    Hope this helps.
    --
    Peter O'Reilly


    Peter O'Reilly Guest

  4. #3

    Default Re: Help with setting expiration dates on COOKIES

    > Since the server is the one issuing the cookie and doing so on their
    'clock'
    > it logically makes sense that the expiration date specified is that of the
    > server.
    Thanks for your response.

    (Assuming that the client and server has the same time zone but for what
    ever reason, the clocks are out of sync.)

    Is this not the problem.
    I mean, the server specifies (logically) 3:00 PM July 27 (expiry for 10 min)
    The client machine has 9:00 PM July 27. So technically, this cookie has
    expired.
    As I understand from the description, the Browser will not issue the cookie
    any more since it is expired
    an it will not get persisted. This is what I observed in some software that
    I'm working with. The symptom is
    that the Login page keeps re-appearing. If I synchronize the time, then the
    problem goes away. However,
    on the internet, I have no control over client's time.

    Thanks
    Rick


    "Peter O'Reilly" <Peter_OReilly@timeinc.com!N!O!.S!P!AM!> wrote in message
    news:utEsT8TVDHA.3232@tk2msftngp13.phx.gbl...
    > Since the server is the one issuing the cookie and doing so on their
    'clock'
    > it logically makes sense that the expiration date specified is that of the
    > server. In other words, the server has no knowledge of what time zone,
    > date, etc. of the requesting client computer. Why should it? It's not
    > necessary and having all the cookies issued timed/date stamped under one
    > clock makes things a whole lot easier for the server to manage state.
    >
    > The server sends cookie information to the requesting source, the web
    > browser. From there, expiration and removal of the cookie is the
    browser's
    > responsibility. In creating the actual cookie (file) the browser may
    > translate GMT to local time when creating the cookie.
    >
    > Hope this helps.
    > --
    > Peter O'Reilly
    >
    >

    Rickey Tom Guest

  5. #4

    Default Re: Help with setting expiration dates on COOKIES

    > Since the server is the one issuing the cookie and doing so on their
    'clock'
    > it logically makes sense that the expiration date specified is that of the
    > server.
    Thanks for your response.

    (Assuming that the client and server has the same time zone but for what
    ever reason, the clocks are out of sync.)

    Is this not the problem.
    I mean, the server specifies (logically) 3:00 PM July 27 (expiry for 10 min)
    The client machine has 9:00 PM July 27. So technically, this cookie has
    expired.
    As I understand from the description, the Browser will not issue the cookie
    any more since it is expired
    an it will not get persisted. This is what I observed in some software that
    I'm working with. The symptom is
    that the Login page keeps re-appearing. If I synchronize the time, then the
    problem goes away. However,
    on the internet, I have no control over client's time.

    Thanks
    Rick


    "Peter O'Reilly" <Peter_OReilly@timeinc.com!N!O!.S!P!AM!> wrote in message
    news:utEsT8TVDHA.3232@tk2msftngp13.phx.gbl...
    > Since the server is the one issuing the cookie and doing so on their
    'clock'
    > it logically makes sense that the expiration date specified is that of the
    > server. In other words, the server has no knowledge of what time zone,
    > date, etc. of the requesting client computer. Why should it? It's not
    > necessary and having all the cookies issued timed/date stamped under one
    > clock makes things a whole lot easier for the server to manage state.
    >
    > The server sends cookie information to the requesting source, the web
    > browser. From there, expiration and removal of the cookie is the
    browser's
    > responsibility. In creating the actual cookie (file) the browser may
    > translate GMT to local time when creating the cookie.
    >
    > Hope this helps.
    > --
    > Peter O'Reilly
    >
    >

    Rickey Tom Guest

  6. #5

    Default Re: Help with setting expiration dates on COOKIES

    Any Comments?
    Thanks
    "Rickey Tom" <rickey_tom@hotmail.com> wrote in message
    news:%239iSEHUVDHA.2104@TK2MSFTNGP10.phx.gbl...
    > > Since the server is the one issuing the cookie and doing so on their
    > 'clock'
    > > it logically makes sense that the expiration date specified is that of
    the
    > > server.
    >
    > Thanks for your response.
    >
    > (Assuming that the client and server has the same time zone but for what
    > ever reason, the clocks are out of sync.)
    >
    > Is this not the problem.
    > I mean, the server specifies (logically) 3:00 PM July 27 (expiry for 10
    min)
    > The client machine has 9:00 PM July 27. So technically, this cookie has
    > expired.
    > As I understand from the description, the Browser will not issue the
    cookie
    > any more since it is expired
    > an it will not get persisted. This is what I observed in some software
    that
    > I'm working with. The symptom is
    > that the Login page keeps re-appearing. If I synchronize the time, then
    the
    > problem goes away. However,
    > on the internet, I have no control over client's time.
    >
    > Thanks
    > Rick
    >
    >
    > "Peter O'Reilly" <Peter_OReilly@timeinc.com!N!O!.S!P!AM!> wrote in message
    > news:utEsT8TVDHA.3232@tk2msftngp13.phx.gbl...
    > > Since the server is the one issuing the cookie and doing so on their
    > 'clock'
    > > it logically makes sense that the expiration date specified is that of
    the
    > > server. In other words, the server has no knowledge of what time zone,
    > > date, etc. of the requesting client computer. Why should it? It's not
    > > necessary and having all the cookies issued timed/date stamped under one
    > > clock makes things a whole lot easier for the server to manage state.
    > >
    > > The server sends cookie information to the requesting source, the web
    > > browser. From there, expiration and removal of the cookie is the
    > browser's
    > > responsibility. In creating the actual cookie (file) the browser may
    > > translate GMT to local time when creating the cookie.
    > >
    > > Hope this helps.
    > > --
    > > Peter O'Reilly
    > >
    > >
    >
    >

    Rickey Tom 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