I'm trying to understand when it's best to use each of the following. Here is my rudimentary understanding:
app.locals -- good for storing global variables at the app level. all users/sessions will see the same values for these variables. the variables are available to all views.
res.locals -- good for storing variables for the specific request/response cycle. the variables are only available to the view associated with the response.
req.session -- good for storing variables associated with the unique user session (e.g., user name). these variables should be available to all views for the unique user/session.
The specific use case I have is as follows: A user runs query which retrieves data from mongodb. I now want the result of this query, which is a JSON array, available as a variable to ALL of the views (HTTP requests). What's the best way to "store" the result array so that each view can access it?