I’m trying to better understand the lifetime of a session and whether there are best practices to minimize session creation and reduce costs.
In my React app, a new session is created like this:
...
const session = await createSession({
ticket: "some-ticket-id",
modelViewUrl: "some-model-view-url"
});
...
I have a few questions and scenarios I’m hoping to get insights on:
- Handling Multiple Products in a Web Store:
Let’s say I have a web store with many products, and each product has its ownmodelViewUrl
andticketId
. As the user browses different products, a new session is created for each product page, consuming credits each time.
Is there a way to load a different model into the existing session while storing the session object somewhere in the context, so we’d only create a new session if the current one has expired/non-existent? - Handling Page Refreshes:
If the user refreshes the page, does this always result in creating a new session? Is there a way to retrieve an existing session using a session ID or some other identifier? Can we check if a session still exists and create a new one only if the old session has expired or there’s no sessions at all in the context?