zoukankan      html  css  js  c++  java
  • jQuery cookie插件保存用户登陆信息

    通过jquery cookie插件保存用户登录信息。
    代码:
    <html> 
    <head> 
    <title>cookies.html</title> 
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 
    <meta http-equiv="description" content="this is my page"> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 

    <style type="text/css"> 
    .txt{ 
     150px; 
    height:20px; 
    border: 1px blue solid; 
    border-radius:0.5em; 
    margin-bottom: 5px; 
    padding-left: 5px; 

    </style> 
    <script type="text/javascript" src="../js/jquery-1.10.2.js"></script> 
    <script type="text/javascript" src="../js/jquery.cookie.js"></script> 
    <script type="text/javascript"> 
    $(function(){ 
    // www.jbxue.com
    if($.cookie("name")){ 
    //取值如果存在则赋值 
    $("#username").val($.cookie("name")); 


    $("#mycookie").submit(function(){ 

    //如果选中了保存用户名选项 
    if($("#chkSave").is(":checked")){ 

    //设置Cookie值 
    $.cookie("name",$("#username").val(),{ 
    expires:7,//设置保存期限 
    path:"/"//设置保存的路径 
    }); 
    }else
    //销毁对象 
    $.cookie("name",null,{ 
    path:"/" 
    }); 

    return false
    }); 

    }); 
    </script> 
    </head> 
    <body> 
    <form action="#" method="get" id="mycookie"> 
    <div> 
    用户名:<br> 
    <input id="username" name="username" type="text" class="txt"> 
    </div> 
    <div> 
    密码:<br> 
    <input id="password" name="password" type="password" class="txt"> 
    </div> 
    <div> 
    <input id="chkSave" type="checkbox">是否保存用户名 
    </div> 
    <div> 
    <input id="cookBtn" class="btn" type="submit" value="提交"> 
    </div> 
    </form> 
    </body> 
    </html> 
  • 相关阅读:
    2行2列分别使用逗号串连起来
    动态获取数据表或临时表列名
    判断临时表是否存在
    RICOH C4502彩色打印机取消双面打印功能
    UNPIVOT逆透视以及动态逆透视存储过程
    动态透视表
    MS SQL的CASE...WHEN...THEN...END语法
    获取数据库中所有触发器
    动态表名,列名,输入参数,输出参数等
    使用CTE生成辅助表(数字或时间)等
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3667808.html
Copyright © 2011-2022 走看看