1、可以执行查、改、增、删当前域下的cookie。默认的domain是当前域。二级域是不能访问在主域下设置的cookie(没有设置domain时)
2、当设置了domain,如domain:a.com时,可以执行查、改、增、删二级域下,如test.a.com的下的cookie,并且在该二级域下同样能执行查、改、增、删该cookie值
3、相同键值,不同域,属于不同cookie。读取该类型的cookie时,获取到的是最先设置的cookie值

4、跨主域的话,大家可以去研究jsonp的原理了。
附:js操作cookie方法
var cookie = cookie || function(cname, value, options) {
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
var path = options.path ? '; path=' + options.path: '';
var domain = options.domain ? '; domain=' + options.domain: '';
var secure = options.secure ? '; secure': '';
document.cookie = [cname, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0,len=cookies.length; i <len ; i++) {
var cookie = cookies[i].replace(/(^\s*)|(\s*$)/g, "");
if (cookie.substring(0, cname.length + 1) == (cname + '=')) {
cookieValue = decodeURIComponent(cookie.substring(cname.length + 1));
break;
}
}
}
return cookieValue;
}
};
浙公网安备 33010602011771号