Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SynchronizePersistentOnLogoutObserver.php
Go to the documentation of this file.
1 <?php
7 
9 
11 
16 {
23 
29  protected $_persistentData = null;
30 
36  protected $_sessionFactory;
37 
45  public function __construct(
46  \Magento\Persistent\Helper\Data $persistentData,
47  \Magento\Persistent\Helper\Session $persistentSession,
48  \Magento\Persistent\Model\SessionFactory $sessionFactory
49  ) {
50  $this->_persistentData = $persistentData;
51  $this->_persistentSession = $persistentSession;
52  $this->_sessionFactory = $sessionFactory;
53  }
54 
62  public function execute(Observer $observer)
63  {
64  if (!$this->_persistentData->isEnabled() || !$this->_persistentData->getClearOnLogout()) {
65  return;
66  }
67 
68  $this->_sessionFactory->create()->removePersistentCookie();
69 
70  // Unset persistent session
71  $this->_persistentSession->setSession(null);
72  }
73 }
__construct(\Magento\Persistent\Helper\Data $persistentData, \Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Model\SessionFactory $sessionFactory)
$persistentSession
Definition: persistent.php:11