How to expire a Cookie using Jquery at midnight?

后端 未结 4 988
南笙
南笙 2021-01-17 21:56

I did this:

$.cookie(\"ultOS\", (i), {expires:1});

But it will only expire next day.

How can I expire a cookie at midnight?

4条回答
  •  旧巷少年郎
    2021-01-17 22:30

    I think this would work:

    var currentDate = new Date();
    expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);
    $.cookie("ultOS", "5", {expires: expirationDate});
    

提交回复
热议问题