After the secondary domain name is enabled in DedeCMS, because dedeajax2 cannot cross domains, it is not successful to use ajax to return login data. There is no better way to cross domains with ajax, so the following method is temporarily used instead.

Cross domain access mechanism:

On the server, documents, data or swf in the same domain can be accessed at will. Cross domain access requires authorization. Note that different domain names will be considered as two domains even if they are mapped to the same IP address. The IP address name and the resolved address are also considered as two domains. Therefore, in this example, even if the secondary domain name is the same IP address, it is also considered as two domains.

Step 1 , create a php file named“ ajax_index_loginsta_s.php ”, use this php file as a condition to determine whether $myurl is empty to determine the login status.

Step 2 , the code filled in this file is:

<? php
require_once(dirname(__FILE__). "/config.php");
AjaxHead();
if($myurl == '')
{
echo "document.write('<div id=_userlogin>');";
echo "document.write('<form name=userlogin action=".$GLOBALS['cfg_cmsurl']."/member/index_do.php method=POST>');";
echo "document.write('<input type=hidden name=fmdo value=login />');";
echo "document.write('<input type=hidden name=dopost value=login />');";
echo "document.write('<input type=hidden name=keeptime value=604800 />');";
Echo "document. write ('<div class=s1>username</div><div class=s2><input type=text name=userid/></div>');";
Echo "document. write ('<div class=s1>password</div><div class=s2><input name=pwd type=password/></div>');";
Echo "document. write ('<div class=s1>verification code</div><div class=s2 id=s2><input name=vdcode type=text maxlength=4/></div>');";
Echo "document. write ('<div class=simg><img src=". $GLOBALS ['cfg_cmsurl']. "/include/vdimgck. php width=50 height=20/></div><div class=s3><input type=submit value=login/></div>');";
Echo "document. write ('<div class=s1><a href=". $GLOBALS ['cfg_cmsurl']. "/member/resetpassword. php target=_blank>Forgot your password?</a><a href=". $GLOBALS ['cfg_cmsurl ']. "/member/index_do. php? Fmdo=user&dopost=regnew target=_blank><font color=# FF0000>Free registration</font></a></div>);";
echo "document.write('</form></div>');";
exit('');
}
$uid = $cfg_ml->M_LoginID;
$face = $cfg_ml->fields['face'] == '' ? $ GLOBALS['cfg_memberurl'].'/ images/nopic.gif' : $cfg_ml->fields['face'];
Echo "document. write ('<div class=s5><b>". $cfg_ml ->M_UserName. "</b>Welcome to XXXXXXXX!<a href=". $cfg_member. "/index. php>Member Center</a>|<a href=". $cfg_member. "/edit_fullinfo. php>Account</a>|<a href=". $myurl. ">My Blog</a>|<a href=". $cfg_member. "/index_do. php? Fmdo=login&dopost=exit><font color=# FF0000>Exit Login</font></a></div>'); ";
?>

Modify it properly yourself. This one is mainly used to log in at the top, so it is placed horizontally.

Step 3 Add a line of code to all the pages that need to be logged in:

<script language="javascript" type="text/javascript" src="//your domain name/member/ajax_index_loginsta_s. php"></script>

Post reply

Can't comment until