微信的一些页面会去获取授权,然后在回调到页面,但是这样的话通过url传递的参数有可能丢失掉,我采用存储cookie的方式来传值 建一个CookieHelper.js文件 function CookieHelper() { } //删除cookie CookieHelper.prototype.deleteCookie = function (name) { var date = new Date(); date.setTime(date.getTime() - 10000); document.…
function cookie(name,value,expires){ switch(typeof value){ case 'string': //设置 var exp=''; if(expires){ var oDate=new Date(); oDate.setDate(oDate.getDate()+expires); exp=';expires='+oDate.toUTCString(); } document.cookie=name+'='+encodeURIComponent(v…
var Cookie = { // 读取 get: function(name){ var cookieStr = "; "+document.cookie+"; "; var index = cookieStr.indexOf("; "+name+"="); if (index!=-1){ var s = cookieStr.substring(index+name.length+3,cookieStr.length); r…
使用cookie(key,value,options) 参数key,value,options(可选) function cookie(key,value,options){ if(typeof value !== "undefined"){//write options=options||{} var cookie=encodeURIComponent(key)+"="+encodeURIComponent(value); if (typeof options.e…