style:cookie
Showing
2 changed files
with
4 additions
and
4 deletions
... | @@ -39,11 +39,11 @@ function GetQueryString(name) { | ... | @@ -39,11 +39,11 @@ function GetQueryString(name) { |
39 | if (r!=null) return (r[2]); return null; | 39 | if (r!=null) return (r[2]); return null; |
40 | } | 40 | } |
41 | // 存储cookie | 41 | // 存储cookie |
42 | function setCookie(resdata,duration){ | 42 | function setCookie(name,resdata,duration){ |
43 | var date = new Date(); | 43 | var date = new Date(); |
44 | date.setTime(date.getTime() + duration*24*3600*1000); | 44 | date.setTime(date.getTime() + duration*24*3600*1000); |
45 | document.cookie = "myCookie=" + JSON.stringify(resdata) | 45 | document.cookie = name + "="+ JSON.stringify (resdata) + ";expires=" +date.toGMTString() + "; path=/"; |
46 | + "; expires=" +date.toGMTString() + "; path=/"; | 46 | // document.cookie = "myCookie=" + JSON.stringify(resdata) + "; expires=" +date.toGMTString() + "; path=/"; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | //获取cookie | 49 | //获取cookie | ... | ... |
... | @@ -87,7 +87,7 @@ function clicklogin(data) { | ... | @@ -87,7 +87,7 @@ function clicklogin(data) { |
87 | data: JSON.stringify(data),//***关键****** | 87 | data: JSON.stringify(data),//***关键****** |
88 | success: function (result) {//返回数据根据结果进行相应的处理 | 88 | success: function (result) {//返回数据根据结果进行相应的处理 |
89 | if (result.code == 200 && result.data !== null) { | 89 | if (result.code == 200 && result.data !== null) { |
90 | setCookie(result.data); | 90 | setCookie('myCookie',result.data,60); |
91 | $('.personalCenter').addClass('show'); | 91 | $('.personalCenter').addClass('show'); |
92 | $('.PersonLogin').html(getCookie('myCookie').username); | 92 | $('.PersonLogin').html(getCookie('myCookie').username); |
93 | layer.closeAll(); | 93 | layer.closeAll(); | ... | ... |
-
Please register or sign in to post a comment