Meteor's session object
The
Session
object provided by Meteor is a reactive data source and serves mainly to preserve global states throughout hot code reloads, though it won't preserve its data when the page is manually reloaded, making it different from PHP sessions.
Note
A hot code reload happens when we upload new code and the server pushes those updates to all clients.
The
Session
object is a reactive data source. This means wherever this session variable is used in a reactive function, it will rerun that function when its value changes.
One use of the session variable can be to maintain global states of our app, for example, to check whether the user has their sidebar visible or not.
The session object is not useful for simple data communication between templates and other parts of the app, as maintaining this would quickly become a nightmare and naming collisions could occur.
A better way for simple reactivity
If we wanted to use something for intra-app communication, it&apos...