jQuery method to control the expiration time of cookie

  • 2020-05-27 04:13:57
  • OfStack

This example shows how jQuery can control the expiration time of cookie. Share with you for your reference. The specific analysis is as follows:

The jquery.cookie () method can be set to cookie. By default, cookie is disabled when the browser is turned off


<script type="text/javascript">
var expiresDate= new Date();
expiresDate.setTime(expire.getTime() + (? * 60 * 1000));
//? Let's substitute for minutes if theta is zero 60 Minutes for  60 * 60 *1000
$.cookie("__cookie__", 'helloworld', {
  path : '/',//cookie The scope of the 
  expires : expiresDate
 });
}
</script>

new Date() setTime() getTime() getTime() new date() and so on

I hope this article has helped you with your jQuery programming.


Related articles: