Meteor: Passing Session values from client to server


#1

I am using the following code on the client side to set the Session variable:

Template.download.events({
    'click button': function() {
        var clientid=Random.id();
        UserSession.set("songsearcher", clientid);
        console.log(clientid + UserSession.get("songsearcher"));

I am using the following pacakge: Meteor-User-session, which will explain the use of UserSession in place of Session.

Now, this works fine.

But When I try to get the Session variable on the server side, which is the reason I am using the above mentioned Package, it gives me the following error in the Developer tools:

UserSession.set @ VM106 benjaminrh_user-session.js?6483f8d2c775bfb11a28a707104fc5cbd79bb6bb:61Template.download.events.click button @ VM120 client.js?c0ec6b46a653f555e1b4403f9469cd8483ddc49c:13(anonymous function) @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3502Template._withTemplateInstanceFunc @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476(anonymous function) @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3501(anonymous function) @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2543Blaze._withCurrentView @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197(anonymous function) @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2542(anonymous function) @ VM112 blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:839jQuery.event.dispatch @ VM108 jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:4698jQuery.event.add.elemData.handle @ VM108 jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:4366

Is this because the package I am using is Deprecated, or you know Meteor changedtheir own code? And if it is, what is the way around?


#2

Sessions are client side only, pass them via a method call if you want to access them


#3

How can that be implemented?


#4

Meteor methods - read here - http://docs.meteor.com/#/basic/methods