javascript - Meteor JS: Shopping Cart Without Login - session id, etc -
i'm working on e-commerce project. customers of e-commerce site able add items shopping cart , checkout without having login.
to this, have decided store items customers add shopping cart inside collection. e.g.
cartitems = new mongo.collection("cartitems");
in order differentiate customer's shopping cart items other customers, have decided add field
var sessid = meteor.default_connection._lastsessionid;
e.g.
{ "_id" : "hco7jysaruybnquc9", "qty" : 1, "productid" : "haajzgxplk4zj3pxw", "session" : "uqtiaeqiawsxlmu7a" }
to document added cartitems collection.
the problem solution whenever page refreshed, last session id changes , therefore cart becomes empty again though same user still using page.
also, documents added collection not cleaned (deleted) have no way of detecting if session going ended browser/user.
1.) what's ideal solution problem?
2.) how implement shopping cart know though page has been refreshed user using site same person , therefore should still keep same items in shopping cart? current solution of using session ids differentiate 1 cart item seems not suitable solution this...
3.) current solution of using last session ids, collection full of cart items session ids past , provide automatic clean-up functionality within app this. what's best way clean-up? there way detect 'end of session'?
thank much.
Comments
Post a Comment