I am trying to save a cookie in which the data of the user who enters is saved.
I only want that data to be there for that day only, therefore at 00:00 it should be deleted.
How could I?
I am trying to save a cookie in which the data of the user who enters is saved.
I only want that data to be there for that day only, therefore at 00:00 it should be deleted.
How could I?
According to this answer in Code Javascript for a cookie that expires at midnight , it would try to do something like this:
That is, you create the cookie and pass the parameter
expires
with the date and time you want it to expire. You generate this date dynamically with the objectDate
and assign the time to 23:59:59.Be careful: the documentation indicates that the time is read in GMT, so if you are in another time zone, adjust it as you see fit.
Setting the expiration time of a cookie is done by setting a date through the expire field as follows: