Ad

How To Resolve Shopify Public App Session Conflicts

I have created a simple embedded public app in shopify using node js for test purpose. It works properly . while i opened two stores in same browser's different tab . I faced the issue of session clash. For example shop domains store1.myshopify.com and store2.myshopify.com were opened in same chrome browser. First i opened store1 it worked properly . Then i opened store 2 it changed the store1 app's session values. Now in both stores app displayed store2 record. I dont know how to handle this . Please guide me how to resolve this issue.

Ad

Answer

It is simple. When you get an incoming request, you can compare the active session store name to the incoming store name. If they differ, you have to close the session, and re-open it for the new store.

Since your App issues a single cookie key for all shops, any open browser tabs would share this, hence the need for you to close/open connections based on the information coming in from the tab.

Note that when you close one session, it means that when you use the tab with that now closed session again, you'll re-authenticate. This means your customer may or may not send in the shop name (especially if your App views have XHR calls without the shop name as a parameter). So be careful there. That can be tricky to handle well.

Ad
source: stackoverflow.com
Ad