Hi, I need to set a cookie to keep user login state. I'm going to hash username, password and IP. My code:
login process:
$hashed = md5($username.$pwd.IP);
setcookie('userstate', $username.':'.$hashed);
restore user state:
$vars = split(':', $_COOKIE['userstate']);
pseudo: get user with username in $vars[0]
$hashed = md5($username.$pwd.IP);
if($hashed == $vars[1]) return true;
else return false;
Is this way safe with XSS attack?