I'm experiencing terrible issue with M2 2.1.4.

I'm creating new user programmatically (without any issues) and then immediatelly I'm doing setCustomerAsLoggedIn():

/* Magento\Customer\Model\Customer $this->customer */
$loginCustomer = $this->customer->loadByEmail('[email protected]');
/* Magento\Customer\Model\Session $this->session */
return $resultRedirect->setPath('customer/account');

But on the top (instead of "Sign In or Create Account") I can't see customer name. If I will log out and then log in - it will appear. How to fix this problem and why this happening?

I check both modes (developer/production) and with cache/without cache.

1 Answer 1


I faced the same issue. The only way I found to update the customer info in the header was by reloading the "customer" section of the localStorage via JavaScript. AFAIK there is no way to do that only in PHP, server side.

Calling customerData.reload(['customer'], true); will trigger an AJAX call to http://www.yoursite.com/customer/section/load/?sections=customer&update_section_id=true&_=some_token. That call returns an object containing the customer data and will trigger the update that replaces the welcome message by the name of the customer.

], function ($, customerData) {
    'use strict';

    customerData.reload(['customer'], true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.