Js跨域同步cookie怎么实现
document.cookie = "name=" + "value;" + "expires=" + "datatime;" + "domain=" + "" + "path=" + "/path" + "; secure";
//name Cookie名字
//value Cookie值
//expires 有效期截至(单位毫秒)
//path 子目录
//domain 有效域
//secure 是否安全
<iframe src='http://网站:1234/test/Index' width='100' height='100' style="display:none"></iframe>
原页面js里 window.location = "http://另外一个网站:1234/GetCookie/Index?" + document.cookie;
跳到另外一个站,
另外一个站获取cookie,设置cookie
var url = window.location.toString();//获取地址
var get = url.substring(url.indexOf("liuph"));//获取变量和变量值
var idx = get.indexOf("=");//获取变量名长度
if (idx != -1) {
var name = get.substring(0, idx);//获取变量名
var val = get.substring(idx + 1);//获取变量值
setCookie(name, val, 1);//创建Cookie
}