1 function setCookie(name,value) 2 { 3 var Days = 30; 4 var exp = new Date(); 5 exp.setTime(exp.getTime() + Days*24*60*60*1000); 6 document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();+ "; path=" + "/" + "; _domain=" + "www.jfinfo.com" + "; secure"; 7 }
调用设置:
1 setCookie(‘name‘,name); 2 setCookie(‘phone‘,mobile); 3 setCookie(‘password‘,mobile);
获取用户登录过得信息:
1 function getCookie(name) 2 { 3 var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); 4 5 if(arr=document.cookie.match(reg)){ 6 return unescape(arr[2]); 7 } 8 else 9 return null; 10 }
获取:
1 getCookie(‘name‘) 2 getCookie(‘phone‘) 3 getCookie(‘password‘)
时间: 2024-11-03 21:19:44