Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor JS Uncaught ReferenceError: Session is not defined

I have a very simple event set up in the \client\main.js file:

Template.hello.events({
  'click button': function () {
    Session.set('selectedPlayer', 'session value test');
    Session.get('selectedPlayer');
    var selectedPlayer = Session.get('selectedPlayer');
    console.log(selectedPlayer);
  }
});

However, whenever I click the button, the console says "Uncaught ReferenceError: Session is not defined" on the row with the first Session.set call.

Other similar questions blame this on the fact that the Session only works on the client and not the server - but as far as I know everything in the folder "client" is automatically client-side.

like image 931
Cos Avatar asked Apr 08 '16 11:04

Cos


1 Answers

I found the answer.

It seems session is no longer part of the default meteor package. You need to run meteor add session for it to work.

like image 198
Cos Avatar answered Sep 21 '22 04:09

Cos