Hi all,
I was wondering what thoughts/ideas people had on the issue of having a "remember me" type function with a login script for a site.
here is the code i use currently, would appreciate some analysis as to potenital flaws, security holes etc.
if($_COOKIE['mySiteUser']) # use cookie to make login persistent
{
if(!$_SESSION['mySiteCustomer']['userID']) # user not logged in then check their cookie
{
$uservals = unserialize($_COOKIE['mySiteUser']);
if($uservals['userIP'] == $_SERVER['REMOTE_ADDR'] && $uservals['userAgent'] == $_SERVER['HTTP_USER_AGENT']) # make sure they are logging in from same IP address and not hijacking cookie
{
$sql = "SELECT `c_id` FROM `customers` WHERE `c_email` = '".mysql_real_escape_string($uservals['userEmail'])."' AND `c_password` = '".mysql_real_escape_string($uservals['userPass'])."'";
$dosql = mysql_query($sql)or die(mysql_error());
if(mysql_num_rows($dosql)==1)
{
$_SESSION['mySiteCustomer']['userID'] = mysql_result($dosql,0);
}
}
}
}
major flaw i know is the issue of someone else using the computer with the stored details but surely that is impossible to prevent without forcing another login.
Thanks.