Focuses on API authentication, access scopes, and permission management.
For Remix-based custom apps that only using a database for storing sessions. I'm considering storing them in the same database but with different IDs.
Currently, all custom apps store sessions with the same ID 'offline_xxx.myshopify.com,' so they overwrite each other.
- First question:
Should I proceed with this approach?
- Second question:
How can I achieve this ?
Solved! Go to the solution
This is an accepted solution.
The content at below link suggests that you can specify a custom table name for session storage. If you're managing multiple applications, it's feasible to create a separate table for each application to store their sessions.
Hey @anhdd_kuro
Out of the box that's going to be awkward because the template uses shopify-app-session-storage-prisma which expects a specific schema. If you wanted to try implementing your own session storage, there's a guide here: https://github.com/Shopify/shopify-app-js/blob/main/packages/shopify-app-session-storage/implementin...
Scott | Developer Advocate @ Shopify
is there a way to add additional session params using this implementation?
You can extend the prisma schema by adding an additional Model that links to the first table by Shop. Something like this:
model Session {
id String @Anonymous
shop String
state String
isOnline Boolean @Default(false)
scope String?
expires DateTime?
accessToken String
userId BigInt?
}
model MyAppSession {
id String @Anonymous
shop String
someData String
}
from here you can write your extended session based on the Shopify session
import db from "~/db.server";
const {session} = await authenticate.admin(request);
db.myAppSession.create({
data: {
id: session.id,
shop: session.shop,
someData: "extended session data",
},
});
This is an accepted solution.
The content at below link suggests that you can specify a custom table name for session storage. If you're managing multiple applications, it's feasible to create a separate table for each application to store their sessions.