Magento2: Peristent cart cookie is not generated for guests and thus persistent cart isn't working

Created on 16 Jan 2018  路  22Comments  路  Source: magento/magento2

When we want to use the Persistent Shopping Cart functionality it does not seem to work for guest users. For guest users the persistent shopping cart cookie isn't created and thus when the session expires the shopping cart is gone.

Preconditions

  1. Magento 2.4
  2. PHP 7.3 | Ubuntu 18.04 LTS | Nginx 1.14.0 or Apache 2.4.29
  3. MySQL 5.7.28

Steps to reproduce

  1. Enable Persistent Shopping Cart in the Backend and set every option to YES
  2. Refresh cache where needed
  3. Go to the Frontend (as a guest / not logged in) and put something in your shopping cart
  4. Verify that the persistent_shopping_cart cookie isn't created (while it should)
  5. Remove the PHPSESSID cookie to clear your session

Expected result

  1. After removing the PHPSESSID cookie the shopping cart should stay intact

Actual result

  1. After removing the PHPSESSID cookie the shopping cart is empty again
  2. No sign of the persistent_shopping_cart cookie that should kick in to preserve the cart
Cookie Clear Description Confirmed Format is valid Ready for Work P1 done Reproduced on 2.2.x Reproduced on 2.3.x Reproduced on 2.4.x

Most helpful comment

Hi guys,

I built an extension for M2, inspired by @clockworkgeek's M1 extension. I must say I haven't tested it in a while, but I don't see a reason why it wouldn't work in M2.3.3.

You can download it here: https://github.com/tig-nl/persistentshoppingcart-magento2

All 22 comments

@GuiltyNL, thank you for your report.
We've acknowledged the issue and added to our backlog.

@irenelagno could you have a look at this please? :)

@magento-engcom-team Hi. We have the same problem in our store. Any updates from your side?

Any updates on this one?

It is a pity it takes so long for this ticket. :(

Persistent shopping cart cookie is created only for a registered user. The cookie contains non-sensitive information and will be used when the user logs off or the session cookie expires.

Well it doesn't make sense to make this option available for registered users only. It should also work for guest users with an expiring session cookie.

Just so you guys know, Shopify keeps guest carts for 2 weeks. Sellers using Magento stores are at a severe disadvantage by not passing some sort of guest persistence.

@emosquito you could always enable the session lifetime to 2 weeks

M2 works the same as M1 in this regard. Guest quotes are never purged so they build up in the database, even if they contain no items. Previously I wrote an (M1 only) extension to take advantage of this by generating a token to match each guest quote and saving it in a cookie. This is a more scalable approach than long session times and is what Persistence is doing for registered customers. The persistent_session table even allows a null customer ID so it wouldn't be that hard to extend it to guests.

Unlike the existing 'remember me' feature on login page, guests are not opting in so implementation must comply with EU cookie law, and since quotes can contain address information GDPR law too. I think the requested behaviour is a huge value add and I fully support it.

The solution that @clockworkgeek gives is a great solution, I would love to see that officially supported in M2.

@erfanimani enabling the session lifetime is not a great solution in general because the session lifetime also affects logged in customers. Keeping customers logged in for 2 weeks could be a security risk for an ecommerce website (Which is why persistent mode exists).

This ticket is now almost a year old. :(

Any update on this? Anyone built an M2 extension?

Any update on this?

Hi guys,

I built an extension for M2, inspired by @clockworkgeek's M1 extension. I must say I haven't tested it in a while, but I don't see a reason why it wouldn't work in M2.3.3.

You can download it here: https://github.com/tig-nl/persistentshoppingcart-magento2

@tig-daanvandenbergh thank you! As it happens I found this after my comment and before yours. I did have some issues... But then I'm having issues getting this to work for logged in users too... so I didn't want to raise issues with your module when I figured I've got other problems.

@tig-daanvandenbergh thanks for the extension. I have loaded it in my M2.3.3 instance, but I am not seeing the TIG section under Stores > Configuration. There are no new sections and I do have the customer persistent cart enabled. Thanks!

Hi guys,

I built an extension for M2, inspired by @clockworkgeek's M1 extension. I must say I haven't tested it in a while, but I don't see a reason why it wouldn't work in M2.3.3.

You can download it here: https://github.com/tig-nl/persistentshoppingcart-magento2

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

:white_check_mark: Confirmed by @engcom-Echo
Thank you for verifying the issue. Based on the provided information internal tickets MC-30119 were created

Issue Available: @engcom-Echo, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

Has this been fixed or not?

The Issue was moved by bot to the Done column by mistake.
Issue is not fixed yet so feel free to take it in progress and propose your solution

Has this been fixed in magento 2.4?

Was this page helpful?
0 / 5 - 0 ratings