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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With