我寫了一個magento控制器,它在客戶會話內存儲了一些過濾器信息。Magento 2丟棄所有會話參數
據Magento的2文檔我使用依賴注入讓Magento的生成我的會話對象:
/**
* @var \Magento\Catalog\Model\Session
*/
protected $_filterSession;
/**
* @param \Magento\Customer\Model\Session $filterSession
*/
public function __construct(\Magento\Customer\Model\Session $filterSession)
{
$this->_filterSession = $filterSession;
}
注射過程是合作得非常好。我可以訪問會話,在其中存儲一個變量並在進一步的調用中返回它。
但是magento似乎不時丟棄整個會話信息。我不能準確地確定magento丟棄信息的時刻,它似乎是隨機的。
下面是代碼:
$this->_filterSession->setFrequency($frequency);
$frequency = $this->_filterSession->getFrequency();
我嘗試了不同的會話作用域但行爲是一樣的。
經過多次嘗試,我嘗試使用PHP會話來存儲信息,但即使這個會話不時被丟棄。
我不知道我在做什麼錯,或者可能是這種奇怪行爲的原因。其他人是否有類似的問題或想法是什麼原因?
由於提前, 托馬斯
我認爲你是對的。我無法確定哪個擴展可以做到這一點,但是由於會話參數丟失了從magento本身使用的會話參數,所以必須有錯誤的擴展。 – thomas