Prabha Vathi
Prabha Vathi

Reputation: 347

How to set a cookie for the beginning of the next day, according to server time?

I want to set PHP COOKIE which should be stored for only one day. Setting a cookie for one day is easier.

If the user visits the site at 6PM, then the cookie should be set for another six hours only.

$tomorrow = mktime(0,0,0,$month,$date+1,$year);

where month, date and year are from the PHP date function. Will the above code work as i expected?

Or is there any better way to do this?

Upvotes: 4

Views: 144

Answers (1)

Boaz
Boaz

Reputation: 20220

Try using the strtotime() function with the tomorrow keyword:

$tomorrow = strtotime('tomorrow');

Upvotes: 6

Related Questions