Sometimes we need to use cookie to save the username to record the login status. How can we correctly determine whether the user cookies exist in the machine? Can't simply use A! = "Writing.
Copy code code as follows:
a = getCookie ("username3");
c_start = document.cookie.indexof ("username3 =");
if (c_start == -1) {
$ ("#login_form"). show ();
$ ("#logined"). Hide ();
}
else {
$ ("#login_form"). hide ();
$ ("#logined"). show ();
$ ("#USSTR"). html (a);
}
The correct method is to determine whether there is a cookie called Username3, and use the document.cookie.indexof ("username3 =") to determine. If the return value is -1, it means that it does not exist.