- // set a cookie
- function SetCookie(name, value, expiredays) {
- var expdate = new Date();
- expdate.setDate(expdate.getDate() + expiredays);
- document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + expdate.toGMTString());
- }
- // get a cookie
- function GetCookie(name) {
- if (document.cookie.length > 0) {
- start = document.cookie.indexOf(name + "=");
- if (start != -1) {
- start = start + name.length + 1;
- end = document.cookie.indexOf(";", start);
- if (end == -1) end = document.cookie.length;
- return unescape(document.cookie.substring(start, end));
- }
- }
- return "";
- }
- //该片段来自于http://www.codesnippet.cn/detail/281120137591.html
来源: http://www.codesnippet.cn/detail/281120137591.html