zoukankan
html css js c++ java
一个非常实用的javascript读写Cookie函数
function
GetCookieVal(offset)
//
获得Cookie解码后的值
{
var
endstr
=
document.cookie.indexOf (
"
;
"
, offset);
if
(endstr
==
-
1
)
endstr
=
document.cookie.length;
return
unescape(document.cookie.substring(offset, endstr));
}
function
SetCookie(name, value)
//
设定Cookie值
{
var
expdate
=
new
Date();
var
argv
=
SetCookie.arguments;
var
argc
=
SetCookie.arguments.length;
var
expires
=
(argc
>
2
)
?
argv[
2
] :
null
;
var
path
=
(argc
>
3
)
?
argv[
3
] :
null
;
var
domain
=
(argc
>
4
)
?
argv[
4
] :
null
;
var
secure
=
(argc
>
5
)
?
argv[
5
] :
false
;
if
(expires
!=
null
) expdate.setTime(expdate.getTime()
+
( expires
*
1000
));
document.cookie
=
name
+
"
=
"
+
escape (value)
+
((expires
==
null
)
?
""
: (
"
; expires=
"
+
expdate.toGMTString()))
+
((path
==
null
)
?
""
: (
"
; path=
"
+
path))
+
((domain
==
null
)
?
""
: (
"
; domain=
"
+
domain))
+
((secure
==
true
)
?
"
; secure
"
:
""
);
}
function
DelCookie(name)
//
删除Cookie
{
var
exp
=
new
Date();
exp.setTime (exp.getTime()
-
1
);
var
cval
=
GetCookie (name);
document.cookie
=
name
+
"
=
"
+
cval
+
"
; expires=
"
+
exp.toGMTString();
}
function
GetCookie(name)
//
获得Cookie的原始值
{
var
arg
=
name
+
"
=
"
;
var
alen
=
arg.length;
var
clen
=
document.cookie.length;
var
i
=
0
;
while
(i
<
clen)
{
var
j
=
i
+
alen;
if
(document.cookie.substring(i, j)
==
arg)
return
GetCookieVal (j);
i
=
document.cookie.indexOf(
"
"
, i)
+
1
;
if
(i
==
0
)
break
;
}
return
null
;
}
查看全文
相关阅读:
template(2.2)
Filter过滤链条
The 3n + 1 problem
Struts2.3+Spring4.0
康托展开
templates(2.1)
templates(1.2)
templates(1.1)
我和你
Android 的上下文菜单: Context Menu
原文地址:https://www.cnblogs.com/chengulv/p/554049.html
最新文章
剑指offer系列30-----删除链表中重复的节点
剑指offer系列29-----链表中环的入口节点-
剑指offer系列28--字符流中第一个不重复的字符
剑指offer系列27--表示数值的字符串
剑指offer系列26--正则表达式匹配
剑指offer系列25---构建乘积数组
剑指offer系列24---数组中重复的数字
剑指offer系列23---字符串排列(不是很理解)
剑指offer系列22--二叉树中和为某一值的路径
RAC下SPFILE文件修改
热门文章
WARNING: Heavy swapping observed on system in last 5 mins.
oracle导入TYPE对象报错ORA-02304
ORA-00445: background process "J000" did not start after 120 seconds
AUD: Audit Commit Delay exceeded, written a copy to OS Audit Trail
ORA-01195: online backup of file 1 needs more recovery to be consistent
expdp导出遇到ORA-31626/ORA-31638/ORA-39077/ORA-6502报错
数据库启动报错:ORA-01102: cannot mount database in EXCLUSIVE mode
ORA-00376:file x cannot be read at this time
ORA-00742:Log read detects lost writein thread 1 sequence 1202 block 137840
template(3.1)
Copyright © 2011-2022 走看看