How to expire a cookie in 30 minutes using jQuery?

后端 未结 3 749
灰色年华
灰色年华 2020-11-27 10:55

How to Expire a Cookie in 30 min ? I am using a jQuery cookie. I am able to do something like this.

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


        
3条回答
  •  醉梦人生
    2020-11-27 11:24

    I had issues getting the above code to work within cookie.js. The following code managed to create the correct timestamp for the cookie expiration in my instance.

    var inFifteenMinutes = new Date(new Date().getTime() + 15 * 60 * 1000);

    This was from the FAQs for Cookie.js

提交回复
热议问题