How to set a cookie to start the next day, depending on server time?

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

If the user visits the site in increments of 6 pm, the cookie should be set only for six hours.

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

where month, date and year is a PHP date function. Will the above code work as I expected?

Or is there a better way to do this?

+4
source share
1 answer

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

 $tomorrow = strtotime('tomorrow'); 
+6
source

Source: https://habr.com/ru/post/1501639/


All Articles