开发者

HttpCookie.Expire timezone implications?

开发者 https://www.devze.com 2023-02-06 14:52 出处:网络
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 Da开发者_

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 Da开发者_如何学PythonteTime.UtcNow.AddDays(1) or the users's timezone plus a day?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号