Let Ecshop shop system users automatically login, open ecshop includes/init.php file, you can find that the Ecshop system to determine the user's session does not exist when it will read the value stored in the cookie. As shown in the following code snippet:
if (Empty ($_session[' user_id '))
{
if ($user->get_cookie ())
{
/* If the member has logged in and has not received the member's account balance, points and coupons */
if ($_session[' user_id ') > 0)
{
Update_user_info ();
}
}
Else
{
$_session[' user_id '] = 0;
$_session[' user_name '] = ';
$_session[' email '] = ';
$_session[' user_rank '] = 0;
$_session[' discount '] = 1.00;
if (!isset ($_session[' Login_fail '))
{
$_session[' login_fail '] = 0;
}
}
}
Search the whole site for $user->logout (); method. The following code can be found in the includes/modules/integrates/integrate.php file:
function Set_cookie ($username = ", $remember = null)
{
if (empty ($username))
{
/* Destroy cookies */
$time = time ()-3600;
Setcookie ("ecs[user_id]", ", $time, $this->cookie_path);
Setcookie ("Ecs[password]", ", $time, $this->cookie_path);
}
ElseIf ($remember)
{
/* Set Cookies */
$time = time () + 3600 * 24 * 15;
Setcookie ("Ecs[username]", $username, $time, $this->cookie_path, $this->cookie_domain);
$sql = "Select user_id, Password from". $GLOBALS [' ECS ']->table (' users '). "WHERE user_name= ' $username ' LIMIT 1";
$row = $GLOBALS [' db ']->getrow ($sql);
if ($row)
{
Setcookie ("ecs[user_id]", $row [' user_id '], $time, $this->cookie_path, $this->cookie_domain);
Setcookie ("Ecs[password]", $row [' Password '], $time, $this->cookie_path, $this->cookie_domain);
}
}
}
Will
$time = time ()-3600;
Setcookie ("ecs[user_id]", ", $time, $this->cookie_path);
Setcookie ("Ecs[password]", ", $time, $this->cookie_path);
After the three lines of code commented out, the exit system will no longer be clear user_id and password cookies, so that when the user logs in, as long as the two cookie value exists will automatically appear as login status.
Reprint: http://www.ecshoptemplate.com/article-1841.html
Let Ecshop shop system users automatically login