For example, if there are two domain names on a website, we need to consider the cookie under two domain names.
What we call cross-domain is lesport.com and le.com.
JS Cookie is not cross-domain, in order to prevent too large.
JS Add Delete and find a whole bunch of online. Recommended below.
We need to understand when the increase, such as the server has a return of the cookie, we need to temporarily add a front-end, must be added under the first domain name (level two domain name can also be added)
var Cookie = {
Set:function (name, value, opt) {
opt | | (opt = {});
var t = new Date (), exp = opt.exp;
if (typeof exp=== ' number ') {
T.settime (T.gettime () + exp*3600000); 60m * 60s * 1000ms
}else if (exp=== ' forever ') {
T.setfullyear (T.getfullyear () +50); Professional Planting Cookie 50
}else if (value===null) {//delete cookie
Value = ';
T.settime (T.gettime ()-3600000);
}else if (exp instanceof Date) {//pass in a Time object
t = exp;
}else{
t = ';
}
Document.cookie = name+ ' = ' +encodeuricomponent (value) + (t && '; expires= ' +t.toutcstring ()) +
‘; Domain= ' + (Opt.domain | | '. le.com ') + '; Path= ' + (Opt.path | | '/') + (opt.secure?) ‘; Secure ': ');
},
Get:function (name) {
name + = ' = ';
var cookies = (Document.cookie | | "). Split (';'),
Cookies,
Namelength = Name.length,
i = cookies.length;
while (i--) {
Cookie = Cookies[i].replace (/^\s+/, ");
if (Cookie.slice (0,namelength) ===name) {
Return decodeURIComponent (Cookie.slice (namelength)). Replace (/\s+$/, ");
}
}
Return ';
}
};
function Cookietool (name, value, options) {
if (typeof value=== ' undefined ') {
return Cookie.get (name);
}
if (options) {
Options.exp = typeof options.expires=== ' number '? Options.expires * 24:
Options.expires; The original cookie is calculated by day.
}
Cookie.set (name, value, options);
}
function getquery (key, URL) {
var Urlargs = URL | | Location.search;
if (urlargs.length > 0 && urlargs.indexof ("?")! =-1) {
var regex = new RegExp (key + "= ([^&]*)", "I"),
result = Urlargs.match (regex);
Return (Result && result.length > 0)? Unescape (result[1]): null;
}
return null;
}
function handler (data) {
if (data && data.vast) {
var cuid = data.vast.cuid;
var Le_cookie = cookietool (' Ark_uuid ');
if (Location.host.indexOf ('. le.com ') >= 0 && cuid && (!le_cookie | | Le_cookie! = cuid)) {
Cookietool (' Ark_uuid ', cuid,{
' Expires ': New Date (2060,00,01, 08,00,01),
' Domain ': '. le.com '
});
Ad User Cookie set to le.com after successful send detection
var srctype = ';
var purl = getquery (' purl ', location.href) | | ‘‘;
if (Purl.indexof ('. lesports.com ') > 0)
Srctype = ' http://ark.letv.com/apsdbg/cm/sport?url= ';
Else
Srctype = ' http://ark.letv.com/apsdbg/cm/cloud?url= ';
var img = document.createelement ("img");
IMG.SRC = Srctype + encodeURIComponent (purl);
Img.onload = function () {
img = NULL;
}
}
}
};
var url = ' Http://ark.letv.com/s?ark=0&ct=0&n=0&res=jsonp&j=handler&callback=handler ';
var script = document.createelement (' script ');
Script.setattribute (' src ', url);
document.getElementsByTagName (' head ') [0].appendchild (script);
Operation of Cookies