I am making this observer class to check if a visitor is logged in.
use Magento\Framework\Event\ObserverInterface; use Magento\Customer\Model\Session; class CheckLoginObserver implements ObserverInterface { /** * @var \Magento\Customer\Model\Session */ protected $customerSession; public function execute(\Magento\Framework\Event\Observer $observer) { //use $customerSession variable here ... } The goal is to use the $customerSession class in the execute function. What's the right way to do that?