
- Meteor Tutorial
- Meteor - Home
- Meteor - Overview
- Meteor - Environment Setup
- Meteor - First Application
- Meteor - Templates
- Meteor - Collections
- Meteor - Forms
- Meteor - Events
- Meteor - Session
- Meteor - Tracker
- Meteor - Packages
- Meteor - Core API
- Meteor - Check
- Meteor - Blaze
- Meteor - Timers
- Meteor - EJSON
- Meteor - HTTP
- Meteor - Email
- Meteor - Assets
- Meteor - Security
- Meteor - Sorting
- Meteor - Accounts
- Meteor - Methods
- Meteor - Package.js
- Meteor - Publish & Subscribe
- Meteor - Structure
- Meteor - Deployment
- Meteor - Running on mobile
- Meteor - ToDo App
- Meteor - Best Practices
- Meteor Useful Resources
- Meteor - Quick Guide
- Meteor - Useful Resources
- Meteor - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Meteor - Session
Sessions are used for saving data while the users are using the app. This data will be deleted when the user leaves the app.
In this chapter, we will learn how to set a session object, store some data, and return that data. We will use the basic HTML setup.
meteorApp.html
<head> <title>meteorApp</title> </head> <body> <div> {{> myTemplate}} </div> </body> <template name = "myTemplate"> </template>
Now, we will store myData locally using Session.set() method. Once the method is set, we can return it using Session.get() method.
meteorApp.js
if (Meteor.isClient) { var myData = { key1: "value1", key2: "value2" } Session.set('mySession', myData); var sessionDataToLog = Session.get('mySession'); console.log(sessionDataToLog); }
If we check the console, we will see that the stored data is logged.

In the next chapter, we will learn how to auto-update templates using the Session variable.
Advertisements