* Replace session with productID.

This commit is contained in:
tianshujie
2021-11-11 10:18:59 +08:00
parent 2ebd3b2b50
commit 41045ea4bc
+2 -2
View File
@@ -146,12 +146,12 @@ class productModel extends model
public function saveState($productID, $products)
{
if($productID == 0 and $this->cookie->preProductID) $productID = (int)$this->cookie->preProductID;
if($productID == 0 and $this->session->product == '') $productID = key($products);
if($productID == 0) $productID = key($products);
if(!isset($products[$productID]))
{
$product = $this->getById($productID);
if(empty($product)) $productID = key($products);;
if($productID && strpos(",{$this->app->user->view->products},", ",{$this->session->product},") === false) $this->accessDenied();
if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false) $this->accessDenied();
}
$this->session->set('product', $productID);
setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);