The example in this article describes how jQuery controls cookie expiration time. Share it with everyone for your reference. The specific analysis is as follows:
The jquery.cookie() method can set cookies. By default, the browser will close the cookie and it will become invalid. Use the following method to solve this problem
<script type="text/javascript"> var expiresDate= new Date(); expiresDate.setTime(expire.getTime() + (? * 60 * 1000)); //?替换成分钟数如果为60分钟则为 60 * 60 *1000 $.cookie("__cookie__", 'helloworld', { path : '/',//cookie的作用域 expires : expiresDate }); } </script>
Here we should pay attention to the capitalization of the methods quoted above: new Date() setTime() getTime() Many people on the Internet are very irresponsible and write new date(), etc. The results are not good, so please pay attention
I hope this article will be helpful to everyone’s jQuery programming.