php记住登陆状态如何完成

WBOY
Release: 2016-06-23 13:19:01
Original
847 people have browsed it

<script type="text/javascript">  var cookie_key = "micro_login_mind_acc";  function submitform() {    if ($("#login_form .circle").length > 0) {      var fm = $("#login_form")[0], exdate = new Date();      exdate.setDate(exdate.getDate() + 30);      if($("#mind_me_a.selected").size() > 0 && fm.account.value){        document.cookie = cookie_key + "=" + escape(fm.account.value) + ";expires=" + exdate.toGMTString();      }else{        document.cookie = cookie_key + "=" + escape(fm.account.value) + ";expires=Sun, 28 Sep 2000 00:00:00 GMT";      }      if (!fm.account.value) {        alert("帐号不为空!");        return;      }      if (!fm.password.value) {        alert("密码不为空!");        return;      }      $("#login_form").submit();    } else {      alert("您好,暂未开放");    }    return false;  }  $(function() {    document.onkeydown = function(e){    var ev = document.all ? window.event : e;    if(ev.keyCode==13) {           //submitform();          // $("#login_form").submit();     }}     $("#login_form").submit(function() {      $.post(this.action, $(this).serialize(), function(data) {        if (data.success) {          location.href = "/server.php";        } else {          alert(data.errors.join(","));        }      }, "json");      return false;    });    //记住我    var coks = document.cookie;    if(coks){      var ckar = coks.split(";");      for(var i in ckar){         var kv = ckar[i].split("=");         if($.trim(kv[0]) === cookie_key) {           $("#login_form")[0].account.value = unescape(kv[1]); } }    }    $("#mind_me_a").click(function(){ $(this).toggleClass("selected"); return false; });  });</script>
Copy after login

<form method="post" id="login_form" action="login.php" onSubmit="return false;">    <p style=" margin-bottom:20px"><label>账号</label><input type="text" name="account" class="gLInp" value="" /></p>    <p><label>密码</label><input type="password" name="password" class="gLInp" /></p>    <div class="gRem"><a id="mind_me_a" href="" target="_blank" class="selected">记住我</a>记住登录状态</div>        <div class="gFgt">       <a href="http://www.test.com/forgectps.php" target="_blank" >忘记密码</a>       <a href="http://www.test.com/forgectps.php" target="_blank">修改密码</a>    </div>    <p class="gAcc submit circle"><a href="#" onclick="submitform();" target="_self">账号登录</a> </p>    <p class="regis">       <a href="http://www.test.com/" target="_blank">         <img  src="/image/Zhuce_1.png"    style="max-width:90%"  style="max-width:90%" / alt="php记住登陆状态如何完成" >       </a>    </p></form>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!