How to expire a Cookie using Jquery at midnight?

后端 未结 4 986
南笙
南笙 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:27

    You can create a Javascript Date object with tonights (midnight) value, then set the expiration as follows:

     $.cookie("example", "foo", { expires: date });
    

    Where date is the date object.

提交回复
热议问题