Understanding lifetime of a session in a web app

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:

  1. Handling Multiple Products in a Web Store:
    Let’s say I have a web store with many products, and each product has its own modelViewUrl and ticketId. 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?
  2. 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?

This is a legit question, I have burnt a lot of credits my self only while develop. I have a Shopify store (Not open yet) with the plugin and like 20-30 products to start, and will end up with 100 or more. If a credit burns for each “try” or start, refreshed page of the configurators and you have some traffic, the credits wont last long. But this may not be a problem depending on the price for new credits, I have not checked that yet :slight_smile:

1 Like
  1. Sessions are bound to the models they are created for, i.e. there is no way to switch a session between models.
  2. A page reload will create a new session. While theoretically it would be possible to reuse sessions across page reloads, this would come with technical caveats and therefore our SDKs do not offer this possibility.

In general, the base amount of credits included with our Starter plan should be sufficient to cover quite some commercial traffic. Please be aware that we offer a developer program to get started.

1 Like