CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1
  1. #1
    Join Date
    May 2001
    Silicon Valley

    Question Time Zones and Cookies Expiration


    As far as I understand, browsers use UTC to check cookies for expiration. That allows to avoid the following situation. Suppose, a server wants to set a cookie with a lifetime of 2 hours. The server uses its own local time, but its in a different time zone 3 hours ahead w.r.t browser. Then the new cookie will be expired upon arrival.

    So far, so good.

    The MSDN reference page for HttpCookie.Expires property doesn't say anything about time zones and provides this example:

    MyCookie.Expires = DateTime.Now.AddMinutes(10.0);
    I was expecting something along the lines of

    OurCookie.Expires = DateTime.Now.ToUniversalTime().AddMinutes(10.0);
    Does the framework automatically convert to UTC ?

    Any suggestion, insight or reference is really appreciated!

    - Nick

    p.s. Found this related thread: How do I set cookie expiration time in user local time?
    Last edited by kender_a; February 21st, 2015 at 09:46 PM.

Tags for this Thread

Posting Permissions

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

Click Here to Expand Forum to Full Width