Meteor session keeps resetting in cart -


i building web store using meteor. having issue meteor session gets reset when item added cart. user can add item cart 2 locations - master products listing page , product detail page.

scenario a: customer on master products listing page , adds item cart. customer clicks on products detail page item. customer adds item cart products detail page. new session created , items added on products listing page disappear , products product detail page in cart.

so problem new session created when item added cart , i'm not sure why that's happening...

here addtocart click event productdetails.js:

'click .add-to-cart': function (e, tmpl) { e.preventdefault();  var quantity = $('[name=qty]').val(); var thisproduct = products.findone(); var sessionid = meteor.default_connection._lastsessionid; var productinfo = {   productcode: thisproduct.productcode,   memprice: thisproduct.memprice,   brand: thisproduct.brand,   size: thisproduct.size,   description: thisproduct.description,   quantity: quantity,   sessionid: sessionid }; session.set('sessionid', sessionid);  console.log(productinfo);  if (quantity > 0) {   meteor.call('addtocart', quantity, productinfo);   router.go('tires'); } else {   alert('please input desired quantity'); } 

}

here addtocart click event master products page:

'click .add-to-cart': function (e, tmpl) { e.preventdefault();  var curruser = meteor.user();    if(!curruser) {   alert("please register account before may add items cart"); } else if (!curruser.profile.confirmed) {   alert("your account needs confirmed before may add items cart. please contact info@info.org assistance.") } else {   var currentrow = $(e.target).closest('tr');   var quantity = currentrow.find('.item-quantity').val();   var sessionid = meteor.default_connection._lastsessionid;   var productinfo = {     productcode: this.productcode,     memprice: this.memberprice,     brand: this.brand,     size: this.size,     description: this.description,     quantity: quantity,     sessionid: sessionid   };   session.set('sessionid', sessionid);    if (quantity > 0) {     meteor.call('addtocart', quantity, productinfo);     currentrow.find('.item-quantity').val(0);   } else {     alert('please input desired quantity');   } }; 

}

and here addtocart method:

addtocart: function(qty, productinfo, cb) {     console.log('//-------------item data-------------');     console.log("product info: ", productinfo);      if (qty > 0) {         cart.insert(productinfo);     } } 

any thoughts? thank in advance!

meteor.default_connection._lastsessionid gives websocket "session" id, not persistent nor way keep track of user session cookie. should rely on user accounts , store cart in profile, or use mongo collection.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -