客户登录条件在 Hostgator 服务器中不起作用

Customer Logged in condition is not working in Hostgator server

我正在开发 OpenCart 3.0.8 网站。我想限制在没有客户登录的情况下显示购物车页面。为此,我在 catalog/controller/checkout/cart.php 中添加了以下条件。

    if($this->customer->isLogged())  {
        if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {......
    }
    else
    {
        $this->response->redirect($this->url->link('account/login'));
    }

在我的系统中,它运行良好。一旦我在没有登录的情况下单击它,它就会移动到登录页面,否则它会显示购物车。但是在 hostgator 中,当我点击购物车时,即使在登录后它也会转到帐户页面。这对我来说很奇怪。

我已与 Hostgator 支持核实,他们说所有必需的扩展都已正确安装。

Curl, ZIP, Zlib, GD Library, Mcrypt, Mbstrings, Xml

在本地和 hostgator 服务器中,都使用 PHP 7.4 版本。没有出现错误日志。任何人都可以提出解决此错误的任何可能性吗?

谢谢

是的。找到了答案。而不是只使用 if($this->customer->isLogged()) ,更改代码如下。

if (!$this->customer->isLogged()) {
    $this->session->data['redirect'] = $this->url->link('checkout/cart', '', true);

    $this->response->redirect($this->url->link('account/login', '', true));
}

谢谢