Magento2: Magento does not set the customer session data correctly.

Created on 27 Sep 2016  路  12Comments  路  Source: magento/magento2

Magento does not set the customer session data correctly.

Issue: After logging in, the customer name in the welcome message (Welcome ) does not get set. At the time of checkout, user is asked to login again. The mini cart does not show the number of products that were added by the customer.

Environment:
Magento: M 2.1.1
Cache: Varnish 4 (only FPC disabled) - Prod mode.
OS version: Ubuntu 14.04.4 LTS
PHP: PHP 7.0.9 (Zend Engine: v3.0.0.)
Apache: Apache/2.4.23
AWS - Bitnami installation.
10K+ SKUs

Steps:

  • Install M2.1.1 on the above stack.
  • Create customer login.
  • Login.
  • The customer name in welcome message is not set.
  • Add product to cart - the mini cart number does not get updated.
  • Checkout - the customer will be asked to login again.

On random browsing thru the site, the name gets set (I am not able to figure out what causes it to set) and then its all fine - the name appears and the mini cart is updated.

This is a consistent issue and can be reproduced every time.

Please treat this as high priority. The sales are getting impacted because of this. Suggest a workaround if any.

Customer Format is not valid needs update bug report

Most helpful comment

This should be fixed in develop branch https://github.com/magento/magento2/commit/861f596371825d9e24672cd613229ae9486c635f. Could you please try this fix.

All 12 comments

I can't reproduce this. Ensure you have permissions set correctly, try clearing magento and browser caches.

Please note that Full Page Cache (FPC) is disabled for now (and might have to keep it that way for sometime for a reason).
When we enable the FPC, the issue is less prominent, but we sill do not get a refresh automatically.

The issue also happens to me on Magento 2.1.1

Yeah, for me also. But not all time (almost)

Have you tried disabling varnish or change application mode?

Varnish is enabled. Mode is production.

I also have the same issue. Frequency of occurrence is always.

Using

Magento 2.1.2
Composer install and upgraded from 2.1.1 to 2.1.2
Debian Jessie 8
PHP7.0 w/ opcache enabled
Mode is developer
Using redis - setup per devdocs
Using varnish - setup per devdocs, but have set,
php bin/magento cache:disable
All 3rd party extension disabled
Stock luma theme.

Steps to Reproduce:

  1. Have had the issue since composer install/upgrade.

What I see:

  1. Using Chrome inspect, nothing is listed in the span
<span class="customer-name" role="link" tabindex="0" data-toggle="dropdown" data-trigger-keypress-button="true" data-bind="scope: 'customer'" aria-haspopup="true" aria-expanded="false">
            <span data-bind="text: customer().fullname"></span>
            <button type="button" class="action switch" tabindex="-1" data-action="customer-menu-toggle">
                <span>Change</span>
            </button>
        </span>
  1. 2016-10-27 21_44_28-my account

Picture above is using porto ultimate theme, but the same thing happens with the luma theme even when all 3rd party modules are disabled.

2016-10-27 22_09_46-

What I expect to see:

  1. There should be some customer name listed when logged in:
    <span data-bind="text: customer().fullname"> some name </span>

which should display the missing name in the ul.header.links and or div.panel.header

  1. Welcome message with customer name

Supplementary info:

I have not tested for issues with the cart.

This should be fixed in develop branch https://github.com/magento/magento2/commit/861f596371825d9e24672cd613229ae9486c635f. Could you please try this fix.

@sevos1984 , with https://github.com/magento/magento2/commit/861f596371825d9e24672cd613229ae9486c635f the customer name and welcome message display after 3 seconds. Good work!

Any reason that there is a delay of 2-3 seconds? Anything I can do to shorten this length of time?

Note: I am running in developer mode with php bin/magento cache:disable
Note: I have not tested the mini cart or the re-login at checkout issue mentioned

I modified ./vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php

since app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php does not exist on a composer install.

The file is modified per the fix as follows:

    public function aroundDispatch(
        \Magento\Framework\App\FrontControllerInterface $subject,
        \Closure $proceed,
        \Magento\Framework\App\RequestInterface $request
    ) {
        $this->version->process();
        if (!$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) {
            return $proceed($request);
        }
        $result = $this->kernel->load();
        if ($result === false) {
            $result = $proceed($request);
            if ($result instanceof ResponseHttp) {
                $this->addDebugHeaders($result);
                $this->kernel->process($result);
            }

Then,

rm -rf ${webroot}/var/view_preprocessed/* ${webroot}/pub/static/*
rm -rf ${webroot}/var/cache/* ${webroot}/var/page_cache/* ${webroot}/var/generation/* ${webroot}/var/di/*
php bin/magento cache:disable
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento --ansi setup:static-content:deploy en_CA
php bin/magento indexer:reindex
php bin/magento cache:flush

Then,

systemctl restart nginx php7.0-fpm
systemctl restart 'varn*'

With enabled cache and production mode this should run faster. You can also enable Merge JavaScript Files, JavaScript Bundling or Minify JavaScript Files to accelerate js. For more information regarding performance configuration contact Community Forums or the Magento Stack Exchange. Thanks.

I've faced this issue after enabling varnish. Anyone solved this issue.

Magento 2.3.2, In /vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php already have following code. Still asking customer to re-login.
if (!$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) { return $proceed($request); }

Was this page helpful?
0 / 5 - 0 ratings