Chirag Lukhi
Chirag Lukhi

Reputation: 1546

Alternative of session variable for Shopping cart in ASP .Net MVC

I want to create shopping cart without using session variable to avoid load on Server.

What is an alternative of session variable for shopping cart in asp.net MVC?

Upvotes: 12

Views: 2478

Answers (3)

Glenn
Glenn

Reputation: 1975

If you want to save some load on your DB as well you could give it try to save the cart in the page itself. Just serialize the cartinformation and store it in a hiddenfield. Very simple and server load effective. The drawback is that that the cart is not remembered for next visit. But for anonymous users it works well. I have done it successfully on various ecommerce sites.

Upvotes: 1

Milan Mendpara
Milan Mendpara

Reputation: 3131

thats a good question

i think you can try for storing shopping cart in cookie ..

it will increase performance and provide less load on server ...

Upvotes: 3

dknaack
dknaack

Reputation: 60486

Then you need to do this using a cookie.

  1. Generate a unique id of your shopping cart and store the id in a cookie
  2. Create the cart, with the id, in your Database
  3. Load /save cart from Database only if you need

Update

Just to make it clear, your shopping cart unique id should be a System.Guid not an int

Upvotes: 6

Related Questions