Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I set cookie expiration time in user local time?

Tags:

c#

cookies

I want a cookie to expire in 10 minutes precisely (just for the sake of argument).

If I use Expires = DateTime.Now.AddMinutes(30) and user is 3 hours behind me, cookie will expire as soon as it is received (is this correct?)

How do I set expiration so it is local to user?

Sure, I can use JavaScript to send that info together with the request, or use a JS-library of some sort to create cookie on the client side, or keep user profile and ask user for time zone, but I am looking a lazy-man solution.

like image 904
THX-1138 Avatar asked Feb 11 '11 18:02

THX-1138


1 Answers

The cookie expiration date will end up as a GMT time, so your code will simply work.

like image 175
Oded Avatar answered Sep 19 '22 12:09

Oded