Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpCookie.Expire timezone implications?

I'm trying to write cookies from my website and I'm trying to figure out what implications timezones has over the HttpCookie.Expire property. Should I be passing DateTime.Now.AddDays(1) or DateTime.UtcNow.AddDays(1) or the users's timezone plus a day?

like image 932
ajma Avatar asked Jan 26 '11 07:01

ajma


1 Answers

If you use a local time, .NET will automatically convert it to GMT when outputting it to the client.

So it doesn't matter for the cookie, but I do suggest to always work with UTC, so at least you can assume that in your data the timezone offset is always 0.

like image 162
Gideon Avatar answered Nov 20 '22 13:11

Gideon