javascript - Meteor.userId not persisting when i refresh the page -


i'm using meteor 0.6.3.1 , have improvised own user system (not user system thought might make use of userid variable since nobody else laid claim it.)

the problem is, variable isn't persisting.

i have code

meteor.methods({     'initcart': function () {         console.log(this.userid);          if(!this.userid) {             var id = carts.insert({products: []});              this.setuserid(id);              console.log("cart id " + id + " assigned");         }          return this.userid;     } }); 

the point being, should able switch pages still use same shopping cart.

i can't use sessions since they're client-side , lead information leaking between users..

how should go doing this? there amplify server-side meteor?

from meteor docs:

setuserid not retroactive. affects current method call , future method calls on connection. previous method calls on this connection still see value of userid in effect when started.

when refresh create new connection. on connection log-in using cookie stored user system on client side.

you can store cart id in cookie...


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -