Reputation: 1807
I need to set a cookie which expires after 4 hours. Now, the users can reside in multiple timezones. So, if I set the cookie in rails and set expiry based on server time, would it lead to invalid expiry times for some users or does rails handle this issue or does browser cookies themselves handle this issue ? Should I set this cookie in javascript, so that user's browser time is taken to set the expiry?
Thanks!
Upvotes: 0
Views: 1555
Reputation: 9747
I think you want to expire cookie after 4 hours since it was set. You just need to specify time that should be ahead of 4 hours from current time. There is no concern with timezone. Because 4 hours is same for all timezones :P
cookies[:login] = { value: "XJ-122", expires: 4.hour.from_now }
Upvotes: 1