Is it acceptable to use sessions for the flow of a web app?

I’m currently building a web app that requires the user to go through a sequence of “pages” to solicit inputs. I’ve been using sessions to propagate across the “views”. For example, the session variable controlling the content of the page and saving the inputs temporarily into sessions before creating a final object towards the end and write to DB.

What Ive noticed that while it doesn’t really make my code more messy, I feel that this pattern gives me a really insecure feeling about what’s happening and it makes me feel messy inside.

Is there a more “acceptable” way?

Thanks! :slight_smile:

Session variables are global reactive variables. So the questions to ask yourself are:

  1. do I need a global variable?
  2. do I need a reactive variable?

If answers are “yes/yes” then you need a Session variable.
If answers are “no/yes” then store a ReactiveVar or a ReactiveDict in whatever scope you see fit (for example your main template, or a singleton object, or whatever).
If answers are “yes/no” then use a javascript global variable.
If answers are “no/no” then store a javascript variable in whatever scope you see fit.


If you are building an Object incrementaly, whose goal is to be wrote in DB at the end, you could also create a local (client-side only) collection as a temporary reactive store for your Object(s).
And with my package, your local collection will persist between hot codes pushes.

One option may be to use is ‘client side collections’ instead of sessions to store temporary data

Then the question becomes: which has the least amount of processing overhead?