Copy codeThe Code is as follows:
// Verify that the password is remembered during page Initialization
$ (Document). ready (function (){
If ($. cookie ("rmbUser") = "true "){
$ ("# RmbUser"). attr ("checked", true );
$ ("# User"). val ($. cookie ("userName "));
$ ("# Pass"). val ($. cookie ("passWord "));
}
});
// Save user information
Function saveUserInfo (){
If ($ ("# rmbUser"). attr ("checked") = true ){
Var userName = $ ("# user"). val ();
Var passWord = $ ("# pass"). val ();
$. Cookie ("rmbUser", "true", {expires: 7}); // store a cookie with a 7-day validity period
$. Cookie ("userName", userName, {expires: 7}); // store a cookie with a 7-day validity period
$. Cookie ("passWord", passWord, {expires: 7}); // store a cookie with a 7-day validity period
}
Else {
$. Cookie ("rmbUser", "false", {expires:-1 });
$. Cookie ("userName", '', {expires:-1 });
$. Cookie ("passWord", '', {expires:-1 });
}
}
The most important lines of code:
Copy codeThe Code is as follows:
$. Cookie (the _ cookie); // read the cookie
$. Cookie (the _ cookie, the _ value); // store the cookie
$. Cookie (the _ cookie, the _ value, {expires: 7}); // store a cookie with a 7-day validity period
$. Cookie ('the _ cookies', '', {expires:-1}); // delete a cookie