I'm setting the cookie in react using react-cookie
this.props.cookies.set("num_tag", num_tag, {
expires: midnight
});
I wanted to reset the value of the cookie when it expires at midnight and not be null.
I'm setting the cookie in react using react-cookie
this.props.cookies.set("num_tag", num_tag, {
expires: midnight
});
I wanted to reset the value of the cookie when it expires at midnight and not be null.
From the documentation, you have to set the expires as an absolute date.
So what you can do is to get the current date, add one day to it and then push the time to midnight.
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(0, 0, 0, 0);
this.props.cookies.set('num_tag', num_tag, {expires: tomorrow});