我的Prestashop网站有这个缓存/ cookie问题,我不确定。
当客户登录时,她点击其他页面,它将再次返回登录按钮而不是欢迎xxx |登出 当他/她点击退出时,他/她仍然有退出按钮,就像她从未注销但如果你强行刷新网站,那么它就会更新。
我认为这是PHP问题,所以我在.htaccess文件中添加了这几行;
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^www.kdtrading.com.au$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^www.kdtrading.com.au$
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
ExpiresActive On
ExpiresDefault "access plus 0 days"
ExpiresByType text/html "access plus 0 minutes"
# Don't cache dynamic pages
<filesMatch ".(php|cgi)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</filesMatch>
但问题仍然存在。
所以我在FrontController.php上添加了这个
if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
{
header("Cache-Control: no-cache, must-revalidate");
$this->context->customer->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
elseif (isset($_GET['mylogout']))
{
header("Cache-Control: no-cache, must-revalidate");
$this->context->customer->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
它仍在那里。