Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys ! I have some confusion over best way to store multiple session values. One of my friend told us that define session 3-4 times is heavy rather then define in a HashTable. Like below scenario : The question is which is better one & why.
C#
Hashtable ht = new Hashtable();
ht.Add("UserID", txtUser.Text);
ht.Add("Type", type.Text);
ht.Add("PaypalID", paypal.Text);
Session["hashtab"] = ht;          //-- Is this better way or below one.

C#
Session["UserID"] = txtUser.Text;
Session["Type"] = type.Text;
Session["PaypalID"] = paypal.Text;


Please light over that in upper scenario my TL told me that hashtable takes minor memory on the server (suppose it takes 500 kb) rather than one by one (suppose it takes 3MB).

Any Suggestions really appreciate ! I really need more advice from you guys.
Posted
Updated 5-Apr-13 2:07am
v4

1 solution

The hashtable would just be an additional overhead, so I don't see any use for it.

The only minor advantage could be if you need to store a particular group of session values together for tracking.
But other than that, I don't see any use for an additional hashtable.
 
Share this answer
 
Comments
Mas11 4-Apr-13 2:45am    
Thanks Abhinav for the answer. Please light over that in upper scenario my TL told me that hashtable takes minor memory on the server (suppose 500 kb) rather than one by one (suppose 3MB).
Abhinav S 4-Apr-13 3:04am    
I'm not sure what he is talking about. I don't believe using a hashtable will provide any benefit in terms of space.
Mas11 4-Apr-13 3:14am    
Thanks Abhinav ! It means I was right.
Abhinav S 4-Apr-13 3:19am    
Well yes. But don't argue with your TL.
Sergey Alexandrovich Kryukov 4-Apr-13 9:29am    
I agree, my 5. It's funny that someone voted 2.
—SA

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