Re: cookie expiry date 01/01/0001

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris R. Timmons (crtimmons_at_X_NOSPAM_Xcrtimmonsinc.com)
Date: 04/22/04


Date: Thu, 22 Apr 2004 10:35:23 -0700


=?Utf-8?B?UmF5?= <anonymous@discussions.microsoft.com> wrote in
news:48FC3104-D6A0-48A4-BED3-978CE0561A70@microsoft.com:

> HI, Chris:
>
> I had tried that.
> It still gives me 01/01/0001 when I displayed the expiry date
> from the cookie collection

Ray,

Exactly. The browser will not send the expiration date of the cookie
back to the server (I don't know why). So trying to read
Request.Cookies["demo"].Expires will never work.

If you only need to know if the cookie has expired or not, the
browser takes care of that by not sending the cookie if it has
expired. However, if you need to know how much time is remaining
before the cookie expires, then you probably need to store another
expiration date in a cookie value so you can read it:

  Response.Cookies["demo].Values["expiration_date"] = ...

and

  daysx.Text = Convert.ToString(
    Request.Cookies["demo"].Values["expiration_date"]);

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/



Relevant Pages

  • Re: deleting cookies and local browser time versus server time
    ... Our server ... is in a different time zone than the browser I'm developing on. ... How can I test cookie expiration with that? ...
    (comp.lang.php)
  • Re: how to delete a cookie?
    ... an expiration date set to 'now' or before. ... The GMT date string representation of epoch appears to be the most reliable ... session cookie, deleted not before the browser session ends (i.e., when all ... browser windows are closed). ...
    (comp.lang.javascript)
  • Re: Attempt to de-mystify AJAX
    ... "Hyperlinks" always open a new browser window. ... key (cookie) is still there and still contains the original value. ... You can get the cookies from the HTTP_COOKIE CGI environment variable. ...
    (comp.databases.pick)
  • Re: NSA Used Cookies to Track Visitors Web Activities?
    ... Could unwittingly installing a compromised browser open the doors wide to cookie-based intrusions? ... A cookie itself is unlikely to be a virus, but if the browser code is written in C, it is very likely to have arrays that are susceptible to "buffer overrun" Sometimes a clever enough person can use such a bug to cause executable code stored in an allegedly non-executable file to replace code in your browser or operating system. ... an external intruder coming in over an Internet connection, presumably that intruder would have access to the cookies on one's machine. ...
    (comp.sys.mac.system)
  • Re: Cookies from ASP.NET app not persisting even when enabled!
    ... > I'm new to ASP.NET and have been developing a small app at work to test ... > and the authorization cookie is saved as expected on the local machine. ... any browser OTHER THAN the one on the development ...
    (microsoft.public.dotnet.framework.aspnet)