让Ecshop网店系统用户自动登陆


让Ecshop网店系统用户户自动登陆,打开ecshop includes/init.php文件,可以发现Ecshop系统判断用户的SESSION不存在的时候会去读取存储在COOKIES里面的值。如下代码片段所示:

if (empty($_SESSION['user_id']))
{
if ($user->get_cookie())
{
/* 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券 */
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;
}
}
}


在全站搜索一下$user->logout();方法。可以在includes/modules/integrates/integrate.php文件中找到如下代码:

function set_cookie($username='', $remember= null )

{

if (empty($username))

{

/* 摧毁cookie */

$time = time() - 3600;

setcookie("ECS[user_id]",  '', $time, $this->cookie_path);

setcookie("ECS[password]", '', $time, $this->cookie_path);



}

elseif ($remember)

{

/* 设置cookie */

$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);

}

}

}

$time = time() - 3600;
setcookie("ECS[user_id]",  '', $time, $this->cookie_path);
setcookie("ECS[password]", '', $time, $this->cookie_path);
三行代码注释掉后,退出系统将不再清楚user_id和password的COOKIE了,这样用户登录的时候只要这两个COOKIE值存在就会自动显示为登录状态。

转载:http://www.ecshoptemplate.com/article-1841.html

智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告