[help] session.get after router redirect

I have LoginTemplate in which I set user session depends on the user’s id from Mongodb, after the session starts I redirect the user to MainTemplate. As I try to session.get the user’s session info on the new MainTemplate the server won’t even start, gives me code error (Unexpected token).

LoginLayout

FlowRouter.go('/main'); Session.setAuth("loggedIn", data); console.log(Session.keys);

MainLayout

Template.MainLayout.events({ var sas = Session.get(keys.data); console.log(sas); });

any ideas what seems to be the problem? :sweat:

The events function expects an object to be passed in. You’re starting to pass in an object by using { }, but then have code inside the { }'s instead of defining a proper JS object.

Check the events section of the docs for more info on how events work. If you just want to dump your session value to see it working, try adding you code into a onCreated Template function.

Template.template.onRendered did the trick!