Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 15, 2012 11:01 AM by Shailendra Saxena
Nov 03, 2012 05:35 PM|LINK
I am working on ecommerce website where i have to develop a Shopping cart. I have created a shopping cart table. I have gone through many articles and tutorials where i have the complete code for cart, but I am unable to understand the way they have done
it and finding difficult to use it.
So i have decide to do it my way with some simple logic where i can have complete control over what i am doing?
I want some help on following things.
1. I want to create a unique id for the user. I would also create a cart id.
2. I want to store this unique user id for further cart items additions.
3. When the user continues to add the items I want to check whether he is the same user. If he is not the same user, then I want to generate a new unique user id .
From product-details.aspx page i m passing the product_id and quantity to cart.aspx page.
I apprecaite your help. Plz guide on this. I m struggling on this.
Nov 03, 2012 05:49 PM|LINK
>> If you want to identify the user only in current session then you can use the session id otherwise you can create a guiid.
string sessionId = this.Session.SessionID;
When you say "further cart items" is in the same session or across multiple visits (close the browser and visit the site later). If you want to identify only for current session then store it in session. Otherwise store the Guid in cookie with some future(x days) expiry.
Your code will check whether the unique id is in session (if you are using session) OR cookie (if you are using cookie). If not, create a guiid and store it in session or cookie.
Nov 03, 2012 08:34 PM|LINK
Thoughts on session state:
Nov 04, 2012 12:38 PM|LINK
Thanks for the reply.
1. I want to keep track of the user for the cureent session only.
2. Further cart item additions - here also i mean the same session and not mutiple site visits. I f he closes the browser then the cart items should be cleared.
One more thing i would like to know is , how can i check whether the unique id is in session (if using session) OR cookie (if using cookie).?
Plz guide on this.
Nov 15, 2012 11:01 AM|LINK
you can use by session. session are on the fly variables
Session["FirstName"] = FirstNameTextBox.Text;
Session["LastName"] = LastNameTextBox.Text;