前些时候一直用cookie等来进行登录页面记住面膜操作,但是由于其存储容量小等缘故,所以后来转向local storage,原理为:当用户勾选记住密码时,local storage 存储用户名密码同时存储记住密码checked,反之则为空;以下为我关于记住密码操作的代码分享

html部分

</head>
<body >
<div class="container1">
<div class="login">
<img src="http://123.56.25.169:8099/esmp/img/log.png" alt=""/>
</div>
</div>
<div id="middle">
<div class="main">
<div class="loginin rt" style="position: relative">
<div class="header">
<img src="http://123.56.25.169:8099/esmp/img/tip.png" alt=""/>
</div>
<div class="mainsection form-group">
<div style="width: 246px;height: 46px; margin-bottom: 18px">
<b class="lf markk"></b>
<input class="lf username" type="text" placeholder="用户名"
id="user" autofocus/>
</div>
<div style="width: 246px;height: 46px;">
<b class="lf markk markk1"></b>
<input class="lf username" type="password" placeholder="密码" autofocus id="password"/>
</div>
</div>
<div class="pw">
<div class="loadingstatus lf">
</div>
<div class="rt" style="font-size: 12px;color: #707070;line-height: 26px;">
<input type="checkbox" class="lf" id="autoLogin"/>
<span class="rem">
自动登录
</span>
</div>
</div>
<div class="footersection" style="text-align: center">
<button id="btn1">登 录</button>
<div class="registerhtml">
<span class="lf">没有账号?</span>
<a href="http://123.56.25.169:8099/esmp/register.html" class="lf">免费注册</a>
</div>
</div>
</div> </div>
</div> </body>
</html> js部分
//记住密码
if($('#autoLogin').is(':checked')) {
localStorage.setItem('username', username);
localStorage.setItem('password', password);
}else{
localStorage.setItem('username', "");
localStorage.setItem('password', "");
} //记住密码end
//用户名密码value获取
$("#user").val(localStorage.getItem('username'));
$("#password").val(localStorage.getItem('password'));
if(localStorage.getItem('username')==""){
$("#autoLogin").attr("checked",false)
}else{
$("#autoLogin").attr("checked",true)
}
//用户名密码value获取end

local storage 简单应用‘’记住密码’的更多相关文章

  1. 基于localStorge开发登录模块的记住密码与自动登录

    前沿||我是乐于分享,善于交流的鸟窝 先做写一篇关于登录模块中记住密码与自动登录的模块.鸟窝微信:jkxx123321 关于这个模块功能模块的由来,这是鸟大大的处女秀,为什么这么说呢?一天在群里,一个 ...

  2. 记住密码超简单实现(C#)

    实现效果如下 实现过程 [Serializable] class User { //记住密码 private string loginID; public string LoginID { get { ...

  3. 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观

    简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...

  4. (转)ASP.NET里面简单的记住用户名和密码

    using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using S ...

  5. Session,Cookie 和local storage的区别

    以前从没有听说过local storage, 在网上查了一些资料,得到如下结论 从存储位置看,分为服务器端存储和客户端存储两种 服务器端: session 浏览器端: cookie, localSto ...

  6. HTML5的LocalStorage实现记住密码

    HTML5 提供了两种在客户端存储数据的新方法: localStorage - 没有时间限制的数据存储 sessionStorage - 针对一个 session 的数据存储 localStorage ...

  7. jquery.cookie.js 操作cookie实现记住密码功能的实现代码

    jquery.cookie.js操作cookie实现记住密码功能,很简单很强大,喜欢的朋友可以参考下.   复制代码代码如下: //初始化页面时验证是否记住了密码 $(document).ready( ...

  8. Web持久化存储Web SQL、Local Storage、Cookies(常用)

    在浏览器客户端记录一些信息,有三种常用的Web数据持久化存储的方式,分别是Web SQL.Local Storage.Cookies. Web SQL 作为html5本地数据库,可通过一套API来操纵 ...

  9. cookie记住密码功能

    很多门户网站都提供了记住密码功能,虽然现在的浏览器都已经提供了相应的记住密码功能 效果就是你每次进入登录页面后就不需要再进行用户名和密码的输入: 记住密码功能基本都是使用cookie来进行实现的,因此 ...

随机推荐

  1. The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.

    Exception when executing ) br is a binary reader. The data to peak is D000 (D0=208) The cause is, fo ...

  2. jquery怎么实现左右滑动的问题

    var len = $("#b span").length, curindex = 0; $("#leftRun").click(function(){ if( ...

  3. 【win8技巧】应用商店里面如何搜索应用app

    win8应用商店搜索app软件的技巧 1.组合键 WIN+C 打开屏幕最右边磁条 2.点击搜索,输入你想搜的软件名称,里面会列出你已经安装的app或者你点击下面的应用商店选项,就可以搜索互联网上应用商 ...

  4. hdu 4778

    知道是状态压缩,但是不会做: 看题解学的: dp[i]表示现在状态是i,先手-后手的分数. #include<cstdio> #include<cstring> #includ ...

  5. new jQuery.common

    var $c=null;jQuery(function(){$c=new jQuery.common(); $c.methods.init(); }); (function($) { $.common ...

  6. 将cocos2dx项目从VS移植到Eclipse

    本文转自:http://www.cnblogs.com/Z-XML/p/3349518.html 引言:我们使用cocos2d-x引擎制作了一款飞行射击游戏,其中创新性地融入了手势识别功能.但是我们在 ...

  7. Design Tutorial: Learn from Life

    Codeforces Round #270 B:http://codeforces.com/contest/472/problem/B 题意:n个人在1楼,想要做电梯上楼,只有1个电梯,每次只能运k个 ...

  8. Ci框架整合smarty模板引擎

    Ci框架整合smarty模板引擎 备注:下载smarty时,最好选择2.6版本,其他测试有坑,ci可以是2.2或其他 大体思路:将smarty封装成ci框架的一个类,然后重新配置一下smarty,这样 ...

  9. 滑动RecyclerView时出现异常: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 6(offset:6).state:30

    RecyclerView 存在的一个明显的 bug 一直没有修复: java.lang.IndexOutOfBoundsException: Inconsistency detected. Inval ...

  10. 【HDOJ】1086 You can Solve a Geometry Problem too

    数学题,证明AB和CD.只需证明C.D在AB直线两侧,并且A.B在CD直线两侧.公式为:(ABxAC)*(ABxAD)<= 0 and(CDxCA)*(CDxCB)<= 0 #includ ...