Question

I have a weird issue that I'm not sure how to solve.

I'm setting a cookie in a wordpress function to expire at midnight the same day:

setcookie("key", 'value', strtotime('tomorrow midnight'), "/", "mysite.com");

However the expiry date showing in the cookie itself is 7pm. I do have a UTC -5 (Eastern Time) setup. I know I can easily add (60*60*5) to the cookie expiry, but I'm not sure if that is a good solution or if there might be something else wrong.

Anyone have any ideas?

Was it helpful?

Solution

I'm not sure about this, but I think you should probably be appending "gmt" to your call to strtotime, like so:

setcookie("key", 'value', strtotime('tomorrow midnight gmt'), "/", "mysite.com");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top