我正在使用react-cookie在react中设置cookie
this.props.cookies.set("num_tag", num_tag, {
expires: midnight
});我想在午夜过期时重置cookie的值,而不是null。
发布于 2020-02-28 16:05:46
在documentation中,您必须将expires设置为绝对日期。
所以你能做的就是得到当前的日期,再加上一天,然后把时间推到午夜。
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});https://stackoverflow.com/questions/60447481
复制相似问题