Meteor Tutorial
Meteor Useful Resources
Selected Reading
- Meteor - Best Practices
- Meteor - ToDo App
- Meteor - Running on mobile
- Meteor - Deployment
- Meteor - Structure
- Meteor - Publish & Subscribe
- Meteor - Package.js
- Meteor - Methods
- Meteor - Accounts
- Meteor - Sorting
- Meteor - Security
- Meteor - Assets
- Meteor - Email
- Meteor - HTTP
- Meteor - EJSON
- Meteor - Timers
- Meteor - Blaze
- Meteor - Check
- Meteor - Core API
- Meteor - Packages
- Meteor - Tracker
- Meteor - Session
- Meteor - Events
- Meteor - Forms
- Meteor - Collections
- Meteor - Templates
- Meteor - First Application
- Meteor - Environment Setup
- Meteor - Overview
- Meteor - Home
Meteor Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Meteor - Session
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> <span> {{> myTemplate}} </span> </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.isCpent) { 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.
![Meteor Session Log](/meteor/images/meteor-session-log.jpg)
In the next chapter, we will learn how to auto-update templates using the Session variable.
Advertisements