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.
1. I want to create a unique id for the user. I would also create a cart id.
>> 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;
2. I want to store this unique user id for further cart items additions.
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.
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 .
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.
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).?
saleem2
Member
56 Points
222 Posts
How Can I Create a User Session either by using cookies or session?
Nov 03, 2012 05:35 PM|LINK
Hi All,
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.
Thanks,
Saleem
Prabakaran_r
Member
672 Points
111 Posts
Re: How Can I Create a User Session either by using cookies or session?
Nov 03, 2012 05:49 PM|LINK
1. I want to create a unique id for the user. I would also create a cart id.
>> If you want to identify the user only in current session then you can use the session id otherwise you can create a guiid.
2. I want to store this unique user id for further cart items additions.
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.
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 .
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.
Mark the response which answers your question.
BrockAllen
All-Star
27534 Points
4907 Posts
MVP
Re: How Can I Create a User Session either by using cookies or session?
Nov 03, 2012 08:34 PM|LINK
Thoughts on session state:
http://brockallen.com/2012/04/07/think-twice-about-using-session-state/
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
saleem2
Member
56 Points
222 Posts
Re: How Can I Create a User Session either by using cookies or session?
Nov 04, 2012 12:38 PM|LINK
Hi Prabakaran_r,
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.
Thanks again,
Saleem
Shailendra S...
Member
551 Points
145 Posts
Re: How Can I Create a User Session either by using cookies or session?
Nov 15, 2012 11:01 AM|LINK
you can use by session. session are on the fly variables
www.techaray.com