With the popularization of HTML5 specifications, we no longer use cookies to realize the password, and the localStorage and local cache are usually used.
For cookies, it only has one document.cookie the API that can be used, whether it is reading cookie or storage cookie, you can only use it
However, LocalStorage, when you store it, there are localStorage.setItem() . When you read, there are localStorage.getItem() . When you want to delete, there are localStorage.removeItem() . The form of storage. So it is easier to use. And the storage space of LocalStorge is large, 5m, and it is permanently stored, unless you take the initiative to delete.
The following is a simple example:
<script src = http://libs.baidu.com/jquery/1.9.1/jquery.min.js> </script> <h3> log in </h3> <input type = text name = user Placeholder = User ID = User> <input Type = Password Name = Pass Placeholder = Password ID = PASS> <input Type = Checkbox ID = ReMember Check> <br /> <br/> <input type = Button value = login ID = sub onClight = loginbtn_click ()> </form> <script type = text/javascript> $ (docume). READY (function () {var strname = localStorage.Getitem ('' Username ');; var strpass = localstorage.getItem (' Userpass'); if (strname) {$ ('#user'). Val (strname);} if (strpass) {$ ('#pass'). Val (strpass);}}); ck () { Debugger var strname = $ ('#user'). Val (); Var Strpass = $ ('#PASS'). Val (); LocalStorage.Setitem ('Username', Strname); if ($ ('' #remember ' ) .s (': Checked')) {LocalStorage.setItem ('Userpass', Strpass);} Else {localStorage.removeItem ('Userpass');} Window.Location.rell oad ();} </Script> SummarizeThe above is the LocalStorage introduced by Xiaobian to remember the user and password function. I hope it will be helpful to everyone. If you have any questions, please leave me a message. Xiaobian will reply to everyone in time. Thank you very much for your support for the VEVB Wulin website!