-2

Which mechanism will be suitable for storing temporary data in Asp.net MVC? I dont want to hit to database everytime customer adds the product to cart.I read some of the articles and i am little bit confused. I want to know which mechanism would be better or any other options? 1) Cookies 2) Session 3) Text File

1 Answers1

0

Sessions and cookies will be what you'll be introduced to in such a case.

Technically cookies will long more time but this is a bit less understandable.

So what a session is? It is something that starts when your user enter your site and follows him until he shuts its browser down.

To provide such a functionality the browser and the server share a token.

That's what's behind the concept of "session".

Basically session storage has a "key=>value" format so to achieve session storage you will have to use a dictionary-like interface:

HttpContext.Current.Session.Add("The Key",the_value);

the_value can be anything serializable.

artragis
  • 3,677
  • 1
  • 18
  • 30