Why is the session not being stored in my custom session table (MySQL) in Shopify app?

Why is the session not being stored in my custom session table (MySQL) in Shopify app?

alfaiz2393
Shopify Partner
5 0 2

Hi everyone,

I'm developing a Shopify app using @Shopify/shopify-app-express and I'm using a custom MySQL session storage by implementing SessionStorage and passing it as sessionStorage in the shopifyApp config.

Here's a summary of my setup:

  • Framework: @Shopify/shopify-app-express

  • Session storage: Custom MySQL (MySQLSessionStorage)

  • Auth flow works — I can visit /api/auth?shop=xxxxx.myshopify.com, get redirected, and hit /api/auth/callback.

  • However, no session is stored in my MySQL session table, even though the OAuth callback is called.

I confirmed:

  • My MySQL connection is working (other queries in the app are fine)

  • The storeSession method is implemented and logs show it's being called

  • No errors appear in the logs during the OAuth flow

Has anyone faced this issue before? Is there something special required in the session config to ensure it's saved? Any help or pointers would be appreciated.

Reply 1 (1)

StevenT_A7
Explorer
156 13 17

Hi Alfaiz,

Please check the following -

  • Verify Session Data: Ensure the session object being stored has valid data (not empty or undefined).
  • Check Database Table: Make sure your MySQL table structure matches the data you're trying to store (e.g., correct column types for session ID and data).
  • Validate Query Execution: Confirm your SQL query is actually writing to the database. Test it manually if needed.
  • Enable Logging: Add logs before and after session storage to verify that the function is running and what it's storing.
  • Review Return Value: Your storeSession function must return true to indicate success.
  • Compare with Shopify’s Example: Look at Shopify’s official MySQL session storage implementation to ensure you're following the right structure.
  • Check for Silent Errors: Look for constraint violations or issues like silent failures in REPLACE or INSERT.

If all these checks pass, your sessions should store correctly. 

If you need more clarifications, do let me know . 

Steven Taylor
302-260-8345