简体   繁体   English

使用cookie,Internet Explorer 9进行PHP日志记录

[英]php logging with cookie, Internet Explorer 9

Why cookies does not work works in IE9, in other browsers it works? 为什么cookie在IE9中不起作用,在其他浏览器中它起作用?

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 它适用于所有主要浏览器,特别是IE

To save cookie: 要保存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. Cookies不写密码和用户名。 It's not safe. 不安全

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM