commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[3.x]: Cart emptied after x minutes despite session or activeCart duration

Open low opened this issue 3 years ago • 4 comments

What happened?

Description

After populating the cart as an anonymous user, the cart is cleared after a time (1h) of inactivity (but browser remains open). The server's gc_maxlifetime setting is set to 24h, as well as Commerce's activeCartDuration. After an hour, I can see the cart still as an active cart in the CP, but it's gone on the front-end, despite the session ID being identical after that time.

Steps to reproduce

  1. Add something to the cart
  2. Wait an hour
  3. Refresh page -- cart empty

Expected behavior

I expected the cart to still hold the product.

Actual behavior

It didn't...

Craft CMS version

3.7.37

Craft Commerce version

3.4.12

PHP version

7.4.3

Operating system and version

Linux 5.4.0-88-generic

Database type and version

MySQL 8.0.28

Image driver and version

Imagick 3.4.4 (ImageMagick 6.9.10-23)

Installed plugins and versions

This list includes a bunch of proprietary plugins:

Algolia 1.0.1 Amazon S3 1.3.0 Audit 2.0.1 Automatic Site Switch 1.0.3 Calendar 3.3.5 Certificates 1.0.0 Converge 1.0.0 Craft Commerce 3.4.12 Element API 2.8.3 Enupal Snapshot 1.2.8 Environment Label 3.2.0 Feed Me 4.4.0 Field Manager 2.2.4 Flat Categories 2.0.0 Forms 3.11.12 Geo Cookie 1.3.3 Hamilton Hubspot 1.0.0 Hamilton Utility 1.0.1 Importer 1.0.0 Inlin 2.1.1 Inventory 1.0.0 LJ Dynamic Fields 3.0.12 Locale Redirector 1.0.1 Mix 1.5.2 OrderExporter 1.0.0 OrderIdentifier 1.0.0 Product Export 1.0.0 Redactor 2.8.8 Retour 3.1.65 RFQ 1.0.0 Sidebar Toggle 3.0.2 SimpleSentry 1.0.0 Super Table 2.6.8 Taxes 1.0.0 Translations v2.0.3 Twig Perversion 2.2.0 Wishlist 1.4.12

low avatar Jun 01 '22 12:06 low

@low Can you check if you have the setting https://craftcms.com/docs/commerce/4.x/config-settings.html#purgeinactivecartsduration set to an hour?

pdaleramirez avatar Jun 24 '22 12:06 pdaleramirez

This will likely be due to the PHP session time. We moved to a cart cookie in Commerce 4 to get around this PHP session limit.

lukeholder avatar Jun 30 '22 12:06 lukeholder

@pdaleramirez It's set to 1 week, actually. @lukeholder It's hosted at Arcustech, and support mentioned they set the gc_maxlifetime value to 24h. Is there a different setting we can tweak to fix this before moving to Commerce 4?

low avatar Jul 04 '22 10:07 low

@low I am not able to reproduce this locally. Could you test this on another server?

pdaleramirez avatar Jul 05 '22 10:07 pdaleramirez

@low did you manage to figure a workaround for this on 3.x?

I am in the same position, hitting this issue but cannot currently upgrade the site to 4.x

iamtompickering avatar Sep 04 '23 14:09 iamtompickering