Magento2: Losing session ocassionally

Created on 6 Feb 2018  路  16Comments  路  Source: magento/magento2

We have some problems with one of our projects. Ocassionally, look's like magento simply redirects to login page when trying to checkout. Is very hard for us to find the problem because happens only sometimes. Because the context of the problem, at first time look hard to reproduce or investigate, but we also found a reproductive method that's generate the same result as the random one. That if you go to /checkout page and simply opens multiple tabs when and paste the same /checkout address into it, the session is lost in browser. This should not be a problem for a customer with a "normal behavior", but neither is normal. The session should be persistent in browser regardless how many requests from how many tabs are opened.

Preconditions

  1. Magento 2.2.2
  2. Varnish
  3. Redis

Steps to reproduce

  1. Login as customer
  2. Add a product in cart
  3. Go to /checkout page
  4. Open tab - paste - enter (multiple times times - 5-6 tabs for example)

Expected result

  1. Checkout page on each tab with session intact.

Actual result

The session is for the current customer and have to re-authenticate into shop
Before lossing the session a rest request to /rest/default/V1/carts/mine/estimate-shipping-methods respond with 401 status code (likely because the cookie don't hit it)

Video link with the method used to reproduce the problem.

Magento2 Lossing session

Format is valid needs update

Most helpful comment

FYI we had the same issue on a 2.2.3 without Redis nor Varnish.
It was quite random but the steps where the same :

  1. Add a product to cart
  2. Go to shopping cart page
  3. Shopping cart page says the cart is empty.

Disabling SID resolved the issue (for the moment at least).

All 16 comments

Try another browser and do the same process, please.
Because just now I face this problem, But no longer it occurs.

I have to same result on Chrome/Firefox. (latest version both)

Could you try without redis and varnish? We need to exclude them from being the cause.

Ce faci @albertomario? Any news?

@albertomario any news? I have the same problem in a live site that was upgrated to 2.2.2, it is magento enterprise.

@albertomario thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please try to reproduce this issue on a clean installation without Redis and varnish on just as @Detzlerr described.

We have the same problem with varnish and without redis. It is not possible to always reproduce it, as @albertomario sad it is occasional. If I repeat the same steps I get an error let's say in 10-15% of cases.

And what we found is the same as @albertomario: "Before lossing the session a rest request to /rest/default/V1/carts/mine/estimate-shipping-methods respond with 401 status code".

It doesn't metter the browser I use.

I can reproduce it in Magento Commerce 2.1.9

@albertomario Unfortunately, we can't reproduce this issue.
We checked the behavior on next configuration

  1. Magento 2.2.2 Open Source (Sample Data) installed through composer
  2. Varnish (version 4.1)
  3. Redis (Configured Redis as session storage)

What settings are missing from this list, in order for us to reproduce the issue?

@albertomario, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

FYI we had the same issue on a 2.2.3 without Redis nor Varnish.
It was quite random but the steps where the same :

  1. Add a product to cart
  2. Go to shopping cart page
  3. Shopping cart page says the cart is empty.

Disabling SID resolved the issue (for the moment at least).

We're also having the same issue on 2.2.0.

  1. Login to customer account
  2. Refresh customer account page, or add a product to basket and go to cart
  3. Shipping method returns 401 and customer returned to /customer/account/login

EDIT:

We are using redis but not varnish.

I am also having the same issue on 2.2.3, however it happens whenever I want to make a payment,
It applies only to logged-in users and not guest.
somehow the payment information api (rest/default/V1/carts/mine/payment-information) return 401
and does not recognize customer's session.

This strange behaviour occurs only when the number of payment methods
quite a lot. In my site, I've integrated around 8 payment methods.

I am using bitnami magento 2.2.3 in google cloud.
the problem happens with or without redis/varnish.

Checks checkout/model/error-processor.js

Having same intermittent error on EE 2.2.3. Also seeing the rest request to /rest/default/V1/carts/mine/estimate-shipping-methods respond with 401 status code before redirecting back to customer log in page. We have guest checkout disabled. Using Redis & Varnish.

In agreement with @kirkmadera that this is likely related to #12362. Possible solutions:

Since applying this patch/upgrading I've not been able to replicate the issue.

Was this page helpful?
0 / 5 - 0 ratings