Skip to content

Customer logged out after changing encryption key

Hey can anyone that have successfully changed encryption key helps me?

I tried changing encryption key on Magento but every time i did, our customer got logged out. (did this on staging/dev environment)

They can log in again and cart data and everything remains, but its very disruptive if this happens on production

Steps taken:

  1. Clone https://github.com/bemeir/magento2-rotate-encryption-keys
  2. run php update-encryption.php scan to get list of db tables with encoded values, this would generate encrypted-values.csv with list of encrypted tables and encoded values
  3. run bin/magento encryption:key:change
  4. run php update-encryption.php update-table --table={TABLE_NAME} --id-field=config_id --field=value --key={NEW_KEY} --key-index=1 --old-key-index=0 --dump=rotation.sql with table names from #2 and the new key generated in env.php

resulting changed/encoded table was only oauth_consumer and core_config table

Can anyone share if there’s any way i can keep my customer’s session after changing the encryption key?

Thank you in advance