从 Prestashop 注销所有客户
Log out all customers from Prestashop
我需要一种方法来从我的 Prestashop 站点注销所有已登录的客户,因为域名迁移导致了一些用户会话问题,让客户注销并重新登录正在解决这个问题。
我尝试了以下代码,但没有用:
$customers = Customer::getCustomers();
foreach($customers as $customer) {
$obj = new Customer($customer['id_customer']);
$obj->logout();
}
有没有办法从 Prestashop(代码或后台)本地 invalidate/destroy 所有用户会话?否则,欢迎使用简单的 PHP 方法。
您必须更改 Prestashop cookie 以避免验证登录。
无法更改 "cookey-key",因为所有密码均失败,但您可以覆盖 Cookie class 并更改 cookie 模式。
我最终的目标与 Mahdi Shad 在他的回答中提到的差不多,但请允许我添加更多细节:
我将 Prestashop cookie 名称的前缀从 "Prestashop-" 更改为 "MySiteName-"(您可以更改为任何您想要的),方法是转到 /classes/Cookie.php
,然后更改以下行 (第 78 行):
$this->_name = 'MySiteName-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);
嗯,覆盖 class 而不是直接修改它肯定是更好的做法。
cookie 名称的这种更改会立即使旧的浏览器 cookie 过时(即使它们没有过期),因此所有用户都会注销。正是我想要的!
我需要一种方法来从我的 Prestashop 站点注销所有已登录的客户,因为域名迁移导致了一些用户会话问题,让客户注销并重新登录正在解决这个问题。
我尝试了以下代码,但没有用:
$customers = Customer::getCustomers();
foreach($customers as $customer) {
$obj = new Customer($customer['id_customer']);
$obj->logout();
}
有没有办法从 Prestashop(代码或后台)本地 invalidate/destroy 所有用户会话?否则,欢迎使用简单的 PHP 方法。
您必须更改 Prestashop cookie 以避免验证登录。
无法更改 "cookey-key",因为所有密码均失败,但您可以覆盖 Cookie class 并更改 cookie 模式。
我最终的目标与 Mahdi Shad 在他的回答中提到的差不多,但请允许我添加更多细节:
我将 Prestashop cookie 名称的前缀从 "Prestashop-" 更改为 "MySiteName-"(您可以更改为任何您想要的),方法是转到 /classes/Cookie.php
,然后更改以下行 (第 78 行):
$this->_name = 'MySiteName-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);
嗯,覆盖 class 而不是直接修改它肯定是更好的做法。
cookie 名称的这种更改会立即使旧的浏览器 cookie 过时(即使它们没有过期),因此所有用户都会注销。正是我想要的!