Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to access the collection of current sessions in ASP.NET?

Is there any way to access the collection of current sessions in ASP.NET globally from the application?

Thanks.

like image 796
flesh Avatar asked Jan 18 '09 12:01

flesh


People also ask

Where are sessions stored C#?

InProc mode, which stores session state in memory on the Web server. This is the default.

Where are .NET sessions stored?

By default, ASP.NET will store session information in memory inside of the worker process (InProc), typically w3wp.exe . There are other modes for storing session, such as Out of Proc and a SQL Server.

What are the collection of session object in ASP?

The Session object stores information about, or change settings for a user session. Variables stored in a Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences.

Where are ASP.NET session variables stored?

Session variables are stored in a SessionStateItemCollection object that is exposed through the HttpContext. Session property. In an ASP.NET page, the current session variables are exposed through the Session property of the Page object.


2 Answers

No, sessions are sandboxed, they are totally separate from each other. What you could do is managing a psueudo-session collection in the shared Application object and implement the Session_Start method to populate that collection.

like image 74
driAn Avatar answered Oct 21 '22 15:10

driAn


If you store session state in SQL Server, you would have access to all the sessions via SQL Server.

There is also Application State - which can be used to access information across the application, but this has many caveats.

like image 24
mson Avatar answered Oct 21 '22 14:10

mson