No matter session is required or not by default your ASP.NET web application will create session for data storage for a user.
A session starts when a user first time hits a web page. if he doesn't do any thing for specific duration the server disposes the session memory allocated for the user. The session expire duration is configured at server. Now when user again hits some page after his session expired the a new session is created again and assigned for user requests.
How can one access the session created by asp.net for the user when he open the site
I belive the
one who is accessing session here is a web developer, well you dont have to do anything special, the .net framework provides Session class for all session related operations.
A web-site user cannot access the Session variables because it is a server side functionality. Imagine if the feature is exposed to web-user he can do blunders to your website.
Additionally if you want to add anything you can simply use Session["yourkeyName"] = "value for the key" it automatically creates the "yourkeyName" key if it doesn't exists and adds value to it and to get the value stored you simply write someVariable = Session{"yourKeyname"].
Hope the answer will clarify the doubts.
Thanks,
Hemant
Hi,
Well there are 2 ways of getting all active sessions it an easy way or a hard way:
1- easy way (i.e. use application level variable to store information)
http://stackoverflow.com/questions/1470334/list-all-active-asp-net-sessions[
^]
http://stackoverflow.com/questions/1347007/how-can-i-view-everything-in-session-state-for-all-active-sessions[
^]
2- hard way (i.e. use reflection)
http://weblogs.asp.net/imranbaloch/archive/2010/04/05/reading-all-users-session.aspx[
^]
Hope it will help.
thanks,
Hemant