cancel
Showing results for 
Search instead for 
Did you mean: 

Show customer data after setCustomerAsLoggedIn()

Show customer data after setCustomerAsLoggedIn()

Im experiencing an issue with Magento 2.1.7

I want to login users programmatically by only their email.

But after setCustomerAsLoggedIn it still shows sign in or create an account in the header.

If I flush the cache it shows the correct data.

 

This issue is the same as https://magento.stackexchange.com/questions/171087/show-customer-name-after-setcustomerasloggedin

 

/* Magento\Customer\Model\Customer $this->customer */
$Customer = $this->customer->loadByEmail('foo@example.com');
/* Magento\Customer\Model\Session $this->customerSession */
$this->customerSession->setCustomerAsLoggedIn($customer);

Thanks in advance!