Let Ecshop shop system users automatically login

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.