Click here to Skip to main content
15,117,719 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a portal which requires three variables specific to particular user, so I am using Session variable for this purpose. This leads to creation of total 4 session variables per user, 1 for authenticating user during login and other 3 according to the requirement.

I want to know whether using session variables in such a manner is apt or not.

Is there any other way to manage these variables other than session variables in order to achieve this task.

You are using four sessions only its nominal and it is the best way instead of using QueryString or any thing else just make sure you are not using set of data like dataset, datatable etc. keep on
Don't worry. You are on the right track. 4 variables per session is not a overhead. If you still don't want it , then you can go the hard way and store the variables in database during the user session and clear them when the user logs out.
Based on the data stored in them, you can also look at using Cookies (as per say, any client side state management technique) Or else, Session sounds good.

Client-Side State Management Objects [^]
A Beginner's Tutorial on ASP.NET State Management[^]
Adittya Gupta 14-Sep-12 2:27am
Don't you think if user delete cookies while using the solution can lead to loss of data that I have saved.
Sandeep Mewara 14-Sep-12 2:38am
Yes I do. Hence I said "based on the data stored in them")...

It's all depend upon your functionality, usage and criticality.

It is fine if you are using 4 session variable per user, but what you are storing is more important then 4 session variable. if you are storing DataSet in the session then it's not preferable. So storing more variable doen't matter, what matter is how much data is stored in session.

Secondly, Session variable is used to persist your data during navigation of the page. Instead you can use QueryString/Cookies/Application/HiddenField/Page.PreviousPage, All depend upon the functionality. If data is not much critical then you can store in cookies as well.

Hope this works for you,
Adittya Gupta 14-Sep-12 2:40am
Data is in string format and too very small but needed in all the pages for specific user as many of tasks are done using them. As data is used in all the pages then using query-string requires lots of effort so I dropped that point.
However I thought of using Application variables but I am not clear that will they be specific to user or will be same for all users.
AmitGajjar 14-Sep-12 2:42am
Application will be common for all user. you can go ahead with session. there is no harm in your case.
AmitGajjar 14-Sep-12 4:07am
Any reason for Negative vote ?
Adittya Gupta 14-Sep-12 8:38am
no negative vote from my side brother. All of your solution is helpful and encouraging me in making confident of choosing right path.
AmitGajjar 14-Sep-12 8:40am

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