下面的函数设置cookie就利用了setcookie(cookiename, cookievalue, seconds, path, domain, secure),同时也可以让它作为cookie删除。
*/
function getcookie(name) {
var cookie_start = document.cookie.indexof(name);
var cookie_end = document.cookie.indexof(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}function setcookie(cookiename, cookievalue, seconds, path, domain, secure) {
var expires = new date();
expires.settime(expires.gettime() + seconds * 1000);
domain = !domain ? cookiedomain : domain;
path = !path ? cookiepath : path;
document.cookie = escape(cookiename) + '=' + escape(cookievalue)
+ (expires ? '; expires=' + expires.togmtstring() : '')
+ (path ? '; path=' + path : '/')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
}