Search by

hryvinskyi / magento2-customer-sign-in-persistent

hryvinskyi

Keeps Magento's "Remember Me" from remembering a customer whose password sign-in waits for its second step, or whose web API token is refused for one: the persistent session and cookie the password check created are deleted in the same request, and the storefront's second step remembers the customer

Package info

github.com/hryvinskyi/magento2-customer-sign-in-persistent

Type:magento2-module

pkg:composer/hryvinskyi/magento2-customer-sign-in-persistent

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-12-03 08:34 UTC

This package is auto-updated.

Last update: 2026-12-03 14:18:21 UTC


README

The bridge between the customer sign-in suite and Magento's persistent shopping cart ("Remember Me"). Magento saves a remembered session when it checks a customer's password, before the sign-in engine holds the sign-in back for its second step. This package takes that remembered session away again, so a password alone never leaves a customer remembered while their second step is still due, nor after a web API token was refused for a second step, and it carries the customer's Remember Me choice to the second step. It adds no page, setting or table.

What it does for a store

  • A sign-in held back for its second step leaves no remembered session. After a storefront action has run, when that request held a password sign-in back for its second step, the persistent cookie is removed from the response, the request's persistent session is emptied, and the persistent session stored for the customer whose sign-in waits is deleted. The customer is not remembered, and the page does not show them as a remembered customer.
  • The choice goes to that sign-in's second step, and to nothing else. The same request keeps the visitor's Remember Me choice, ticked or not, in their checkout session, together with the pending sign-in it was made for: its customer, website, first method and the moment the password was accepted. The request that answers the second step of that very pending sign-in and opens the customer's session uses it, so the customer is remembered only if they ticked the box, not as the store ticks it by default. Any other sign-in in the same browser session never uses it: a passkey or email-code sign-in, or the second step of a later pending sign-in after the first was cancelled or replaced, is remembered as the store ticks the box. The kept choice is dropped once that second step has signed the customer in, and when a second step finds no pending sign-in or one the choice was not kept for; a wrong code leaves it for the next try.
  • A refused web API token leaves no remembered session. When a REST or SOAP customer token is refused because the account needs a second step, or because the store requires a second step the customer has not set up, the persistent cookie is removed from the response, the request's persistent session is emptied, and the customer's stored persistent session is deleted. The refusal still reaches the caller. GraphQL saves no remembered session on its password check, so there is nothing to undo there.
  • Everything else is as Magento does it. A sign-in that needs no second step is remembered as Magento does it. An issued token, and a token refused for a wrong password, leave the remembered session as it is. A request that held nothing back keeps its remembered session, whatever pending sign-in an earlier request left.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.x. The suite is built and tested on 2.4.9.
  • PHP 8.1 to 8.5.
  • hryvinskyi/magento2-customer-sign-in-api ^1.0, and the platform's Persistent, Checkout, Customer and Integration modules.
  • The sign-in engine, hryvinskyi/magento2-customer-sign-in ^1.0, which implements the contracts this package reads; Composer installs it with this package.

Installation

Run from the Magento root. hryvinskyi/magento2-customer-sign-in-pack installs this package with the rest of the suite.

composer require hryvinskyi/magento2-customer-sign-in-persistent
bin/magento module:enable Hryvinskyi_Clock Hryvinskyi_RateLimit Hryvinskyi_VerificationCode Hryvinskyi_CustomerSignInApi Hryvinskyi_CustomerSignIn Hryvinskyi_CustomerSignInPersistent
bin/magento setup:upgrade
bin/magento setup:di:compile  # production mode only
bin/magento cache:flush

Verify: bin/magento module:status Hryvinskyi_CustomerSignInPersistent prints Hryvinskyi_CustomerSignInPersistent : Module is enabled.

Configuration

None of its own. It has an effect only while Magento's persistent shopping cart is on: Stores > Settings > Configuration > Customers > Persistent Shopping Cart > General Options, Enable Persistence (persistent/options/enabled) and Enable "Remember Me" (persistent/options/remember_enabled). "Remember Me" Default Value (persistent/options/remember_default) is what the box shows; the customer's own choice is what this package carries to the second step.

Stored data

None of its own. It deletes the customer's rows of the platform's persistent_session table, and keeps the Remember Me choice, with the pending sign-in it was made for, in the checkout session under customer_sign_in_kept_remember_me. The platform's own remember_me_checked key, which every sign-in reads, is not written.

Limits

  • Remembered only as the box was left on the sign-in page. A sign-in that needed a second step is remembered, or not, as the customer left Remember Me when they entered their password. The second step offers no box of its own.
  • A cancelled or replaced pending sign-in leaves its choice behind, unused. The kept choice stays in the browser's session until the next second step or the next password sign-in held back for a second step drops or replaces it. No sign-in reads it in the meantime.
  • REST and SOAP only. The token plugin is registered in the webapi_rest and webapi_soap areas.

Registrations

Where What
Event controller_action_postdispatch (frontend) Observer\ForgetRememberedSessionOfParkedSignIn forgets the remembered session of a sign-in the action held back.
Plugin around on Magento\Integration\Api\CustomerTokenServiceInterface::createCustomerAccessToken (webapi_rest, webapi_soap) Plugin\Integration\ForgetRememberedSessionOfRefusedToken forgets the remembered session when the token is refused with VerificationRequiredException or SecondStepSetUpRequiredException.
Plugin around on Hryvinskyi\CustomerSignInApi\Api\VerificationGateInterface::verify (frontend) Plugin\SignIn\RememberMeOfSecondStep hands the choice kept for the session's pending sign-in to the second step that may finish it.
Preference Model\RememberedSessionInterface → Model\PersistentRememberedSession.
Preference Model\RememberMeChoiceInterface → Model\PersistentRememberMeChoice, with the checkout session as a proxy, so it starts only when a kept choice is written or read.

The package registers no route, table, setting, ACL resource, cron job or command.

Versioning

The package follows Semantic Versioning. What changed in each version is in CHANGELOG.md.

Tests

Run from the Magento root.

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/CustomerSignInPersistent/phpunit.xml.dist.
  • Integration: the platform's harness in dev/tests/integration, one run at a time against its own database. cd dev/tests/integration && php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../app/code/Hryvinskyi/CustomerSignInPersistent/Test/Integration.
  • Static analysis: PHPStan 2.x at level 10 with the package's phpstan.neon.dist (phpstan analyse -c app/code/Hryvinskyi/CustomerSignInPersistent/phpstan.neon.dist --level=10), and vendor/bin/phpcs --standard=app/code/Hryvinskyi/CustomerSignInPersistent/phpcs.xml.dist app/code/Hryvinskyi/CustomerSignInPersistent.