Cookie Save Login After login successful Setcookie is a value closed browser in the first page to read the value of the solution
Cookies are saved at logon
if (empty ($c)) {
echo "does not exist username or password error!"; Exit
}else{
if (isset ($_post[' checked ')) && $_post[' checked ']!=0) {
Setcookie (' username ', $c [' username '],time () +60*60*24*7);
Setcookie (' id ', $c [' ID '],time () +60*60*24*7);
}
Determine if it is an AJAX request
if (Isset ($action)) {
echo "Landing success";
$_session[' user ']= $c [' username '];
}else{
$_session[' user ']= $c [' username '];
Header ("location:/");
}
}
Home judgment
Public Function Index ()
{
Session_Start ();
Print_r ($_cookie);
if (Isset ($_cookie[' id ')) && isset ($_cookie[' username ')) {
echo $_cookie[' username '];exit;
$_session[' user ']=$_cookie[' username ';
}
$this->display ();
}
Cookie value can not be found, I would like to ask this information security? How to improve.
------Solution--------------------
Cookie Usage Error
Setcookie (' username ', ' username ', Time () +60*60*24*7);
Setcookie (' id ', ' id ', time () +60*60*24*7);
------Solution--------------------
if (empty ($c)) {???
I don't know how much code you omitted before.
Since there is a conditional access to the cookie Settings branch, then you must first confirm that the branch entered and then test it?
------Solution--------------------
You see if this is done.
if (isset ($_post[' checked ')) && $_post[' checked ']!=0) {
Setcookie (' username ', ' ssssss ', Time () +60*60*24*7);
Setcookie (' id ', ' + ', Time () +60*60*24*7);
}
------Solution--------------------
Close the browser on the first page to read the value Solver
------Cookies are saved on the client and disappear as your browser shuts down.
------Solution--------------------
After successful landing, did you point out the exit and then close the browser ah? Then reopen the home page cookie is gone?
If you do not exit, it is recommended that you change other browsers to see if the same results ...
Must not login after the point of exit and then close the browser ha ~ ~
------Solution--------------------
Set the path of the cookie to look at,