How to set a cookie for minutes using jQuery.
Download & Include jquery.cookie.js from : https://github.com/carhartl/jquery-cookie
Check if cookie exits
if($.cookie('freq') == null) { }
Insert a cookie that expires in 5 Minutes.
var date = new Date(); var minutes = 5; //how many minutes you want the cookie to expire in date.setTime(date.getTime() + (minutes * 60 * 1000)); $.cookie("freq", "1", { expires: date, path : '/' });
Complete code below.
if($.cookie('freq') == null) { var date = new Date(); var minutes = 5; //minutes you want the cookie to expire in date.setTime(date.getTime() + (minutes * 60 * 1000)); $.cookie("freq", "1", { expires: date, path : '/' }); //do something }
The post jquery – setting cookie using jquery appeared first on Ujwal Trivedi.