简体   繁体   中英

Cookie expiry set for minutes and not days

I'm using a free plugin for Wordpress, that seems the author is not very proactive unfortunately, although it is a super useful and great plugin.

So I got an issue, as in the config for the plugin, it allows you to set an expiration time for a cookie in days, but I would like to know if it's possible so i can amend the code and set it for minutes or seconds.

So I went into the plugin files, and found what I think is the actual piece of code that sets the cookie (sorry, but I'm not a programmer so I can't really tell what this code does) so i was wondering if someone can confirm me if that is the actual code that controls the cookie expiration, and if it can be changed to accomplish what I need.

This is the code:

!function(e){var n=!1;if("function"==typeof define&&define.amd&&(define(e),n=!0),"object"==typeof exports&&(module.exports=e(),n=!0),!n){var o=window.Cookies,t=window.Cookies=e();t.noConflict=function(){return window.Cookies=o,t}}}(function(){function e(){for(var e=0,n={};e<arguments.length;e++){var o=arguments[e];for(var t in o)n[t]=o[t]}return n}function n(o){function t(n,r,i){var c;if("undefined"!=typeof document){if(arguments.length>1){if(i=e({path:"/"},t.defaults,i),"number"==typeof i.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}i.expires=i.expires?i.expires.toUTCString():"";try{c=JSON.stringify(r),/^[\{\[]/.test(c)&&(r=c)}catch(f){}r=o.write?o.write(r,n):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),n=encodeURIComponent(String(n)),n=n.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),n=n.replace(/[\(\)]/g,escape);var s="";for(var p in i)i[p]&&(s+="; "+p,i[p]!==!0&&(s+="="+i[p]));return document.cookie=n+"="+r+s}n||(c={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,l=0;l<d.length;l++){var C=d[l].split("="),g=C.slice(1).join("=");'"'===g.charAt(0)&&(g=g.slice(1,-1));try{var m=C[0].replace(u,decodeURIComponent);if(g=o.read?o.read(g,m):o(g,m)||g.replace(u,decodeURIComponent),this.json)try{g=JSON.parse(g)}catch(f){}if(n===m){c=g;break}n||(c[m]=g)}catch(f){}}return c}}return t.set=t,t.get=function(e){return t.call(t,e)},t.getJSON=function(){return t.apply({json:!0},[].slice.call(arguments))},t.defaults={},t.remove=function(n,o){t(n,"",e(o,{expires:-1}))},t.withConverter=n,t}return n(function(){})});

Thanks in advance

I give it another try today, and as charlietfl said if you use decimals it worked. My mistake was that i tried decimas with , (coma) instead of . (dot).

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM