Click here to Skip to main content
15,997,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If you add a value in session variable and again you have add another value in same session variable how to retrieve both value from this variable

What I have tried:

I am work on shopping cart project
Posted
Updated 14-Feb-19 0:22am

1 solution

You can't store multiple objects in a Session variable. If you want to store more than one thing you'll need to use a List or similar

var basket = new List<Product>();
basket.Add(new Product { ... });
basket.Add(new Product { ... });
Session["Basket"] = basket;


So if you only have one thing in the basket then it will still be a list but with only one item.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900