Why cookies does not work works in IE9, in other browsers it works?
In logging in i use a code
$expires = 60 * 60 * 24 * 365;
$time = time() + $expires;
setcookie ("username", $user, $time, "/");
setcookie ("password", $pass , $time, "/");
And in logging out i use code
$expires = 60 * 60 * 24 * 365;
$time = time() - $expires;
setcookie ("username", "", $time, "/");
setcookie ("password", "" , $time, "/");
In checking a logged user i use
if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
$result = mysql_query ( "select * from users where user=$_COOKIE['username'] and passwd=$_COOKIE['password']" );
while ( $row = mysql_fetch_assoc ( $result ) ) {
return $row;
}
return array();
}
How to solve that logging works in all browsers? Thank you for hints
Regards
It works in all major browsers, specially IE
To save cookie:
setcookie('username', trim($username), time() + 6000000, '/');
setcookie('password', trim($password), time() + 6000000, '/');
To remove it:
setcookie('username', '', 0);
setcookie('password', '', 0);
unset($_COOKIE['username']);
unset($_COOKIE['password']);
Cookies do not write the password and user name. It's not safe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.