zoukankan      html  css  js  c++  java
  • 记住用户名和密码

    后台:
       登陆成功之后将用户名密码放入到cookie中   
       // 放到cookie中  
        String flag = request.getParameter("flag"); 
        if(flag!=null && flag.equals("1")){ 
          Cookie cookieUser = new Cookie("cookie_user", userId+"-"+userPwd);
          cookieUser.setMaxAge(60*60*24*30*120);  
          response.addCookie(cookieUser);  
        }else{
          Cookie cookie = new Cookie("cookie_user",null);   
          cookie.setMaxAge(0);   
          response.addCookie(cookie); 
        }
    
    前台:(注意需要引入jquery.cookie.js)
    
        <div class="mui-input-row">
          <label>账号</label>
          <input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
        </div>
        <div class="mui-input-row">
          <label>密码</label>
          <input id='password' type="password" class="mui-input-clear mui-input-password" placeholder="请输入密码">
        </div>
        <li class="mui-table-view-cell">
           记住用户名和密码
           <input id="flag" type="hidden" name="flag" value="1"/>
        </li>
    
        //读取Cookie值
        var cookiesUser = $.cookie("cookie_user");
        if (cookiesUser != undefined) {
            $("#account").val(cookiesUser.split('-')[0]);
            $("#password").val(cookiesUser.split('-')[1]);
        }

     百度云盘链接:https://pan.baidu.com/s/1QnKQOq3xW6OlrGYLdVkgqQ 密码:j3yv

  • 相关阅读:
    169. Majority Element
    283. Move Zeroes
    1331. Rank Transform of an Array
    566. Reshape the Matrix
    985. Sum of Even Numbers After Queries
    1185. Day of the Week
    867. Transpose Matrix
    1217. Play with Chips
    766. Toeplitz Matrix
    1413. Minimum Value to Get Positive Step by Step Sum
  • 原文地址:https://www.cnblogs.com/gaomanito/p/8876203.html
Copyright © 2011-2022 走看看