Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Meteor session variables getting cleared on page refresh

I just noticed in my meteor app that the session variables are getting cleared on page refresh. So

  1. How is meteor saving user login details ?
  2. Are they not saved in session ?
  3. How can this issue be managed ?
like image 571
I'm nidhin Avatar asked Oct 02 '22 00:10

I'm nidhin


1 Answers

Meteor.Session is only for the client-side. It's a JavaScript global object in your application. If you refresh the page it's wiped out. Your session is stored in client-side localStorage, https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage. Meteor does not use cookies for Session, https://www.meteor.com/blog/2014/03/14/session-cookies.

You would need to explain more what you are trying to accomplish. I use Meteor.Session once the page is loaded, and not for many things, but to get my initial state of things, my URLs contain enough info to set initial state.

With Meteor you ideally do not want to refresh the browser. Everything happens or should happen with AJAX and HTML5 push state ideally and Meteor's reactiveness.

You should read their documentation. Here's the section on Session, http://docs.meteor.com/#session

like image 144
nickytonline Avatar answered Oct 03 '22 14:10

nickytonline