SSO a section of JS script for writing cookies across domains (recommended) _javascript tips

Source: Internet
Author: User
Tags script tag setcookie
<meta http-equiv= "Content-type" content= "text/html;
 Charset=utf-8 "/> <script> var setcookitarray =" "; Setcookitarray = "[\" http://passport.a.com/main/setcookie.do?domain=\ ", \" http://passport.a.com/main/setCookie/ Main/setcookie.do?domain=.b.cn\ ", \" http://passport.a.com/main/setcookie/main/setcookie.do?domain=.c.com\ ", \"
 Http://passport.a.com/main/setcookie/main/setcookie.do?domain=.d.cn\ "]"; 
 Setcookitarray = eval (setcookitarray); 
 var setcookitarrayln = setcookitarray.length;
 alert (SETCOOKITARRAYLN);
 var Notifyurl_list=setcookitarray;
 var ll = Setcookitarrayln; var params= "Yqvg1ennsnnxydeq4azcap6tjhr90qceutb7gs45h08ltxbuneoy_ gczvyqc6cvzewpgn0al8xwkdsit60yo1qsulbk0fip73xz@7djs3zmhbbadanmbuh1y@mvd2@ @keR0S7njF5xiy @m6zarwynmbj23jldsrvetmj0bexfyvffe
 @twp3RHfD41dJOQzWz @nf8i@tjb12hnlig4ow0ea== ";
 var failuretime=2678400;
 var backurl= "http://www.test.com";
 
 Alert ("1111");
 Loginall (Notifyurl_list, Ll-1, Backurl, params,failuretime);
 Alert ("2222"); Function LogiNall (notifyurl_list,num,backurl,params,failuretime) {var u = notifyurl_list[num];
    Alert ("URL:" + (num) + "-" +u);
      if (typeof u!= "undefined") {//alert ("4444:" +notifyurl_list[num]);
			var url = notifyurl_list[num]+ "&failuretime=" +failuretime+ "&val=" +params;
			
			Alert ("URL:" +url);
			Dynamically generate script Script tag execute URL page var login=request ("Loginscript" +num,url);
      num--;
        if (num < 0) {window.settimeout (function () {window.location.href = Backurl;
				
      }, 2000);
			else {loginall (notifyurl_list, num, Backurl, params,failuretime);
   }} function request (Id,url) {oscript = document.getElementById (ID);
   var head = document.getElementsByTagName ("Head"). Item (0);
   if (oscript) {head.removechild (oscript);
   } Oscript = document.createelement ("script");
   Oscript.setattribute ("src", url);
   Oscript.setattribute ("id", id);
   Oscript.setattribute ("type", "Text/javascript"); OScript.setattribute ("Language", "JavaScript");
   Head.appendchild (Oscript);
return oscript; } </script> <body> </body>

The page is invoked mainly by recursive invocation and dynamically creating a script tag.

Above this SSO cross domain writes the cookie a section of JS script (recommendation) is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.