Using the Session object
The Session object is a global client-side object, and as such, is part of the client model. Though it's not part of any collection, the Session object can be used in a reactive context, which means you can use it to make reactive methods rerun whenever it is changed. This recipe will show you how to use the Session object to update the elements on your page.
Getting ready
You will need to have Meteor installed and a project created. To create a standard project file structure, please see the Setting up your project file structure recipe in Chapter 1, Optimizing Your Workflow. A quick default project will work just as well for this recipe.
How to do it…
To use the Session object, proceed with the following steps:
Open the
main.js
file in your client'sscripts
folder([project root]/client/scripts/main.js
) and add agreeting
helper to the beginning ofTemplate.hello.helpers
, as follows:Template.hello.helpers({ greeting: function() { return Session.get('greeting')||'Welcome...