Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will my cookie actually expire?

Tags:

I have an ASP.NET application running on a server in California. The server's current time is:

  • 7/20/2015 14:00 UTC-08:00

Bob is connected to my server. Bob is in Texas. His current time is:

  • 7/20/2015 16:00 UTC-06:00

My application creates a cookie and set its expiration date.

var name = "MyName";
var value = "MyValue"
var hoursToLive = 24;

var myCookie = new HttpCookie(name )
{
    Value = value,
    Expires = DateTime.Now.AddHours(hoursToLive)
};

Will the cookie expire in 24 hours, or will it expire in 22 hours due to the time difference between Bob and the server? I know that DateTime.Now uses the server's local time, but I am unclear as to how browsers decide that a cookie is expired (specifically, what time zone is used to determine expiration).