edit sessions in ASP.NET. How?

  • Thread starter Thread starter Paul Oak
  • Start date Start date
P

Paul Oak

hi all,
i have a question regarding the sessions or so called memory cookies
in ASP.NET. Is there a way all the current sessions to be viewed and
edited somehow? For example: I have opened 5 different aspx web
applications, which have created 5 different sessions. Now, I want to
be able to view the content of all of their sessions and to edit them.
An example of source code or hint for a tool, which does this is
really appreciated.

10x in advance
Paul
 
Paul Oak said:
hi all,
i have a question regarding the sessions or so called memory cookies
in ASP.NET. Is there a way all the current sessions to be viewed and
edited somehow? For example: I have opened 5 different aspx web
applications, which have created 5 different sessions. Now, I want to
be able to view the content of all of their sessions and to edit them.
An example of source code or hint for a tool, which does this is
really appreciated.

This sample show you how interact with HttpSession object:

for(int i = 0; i < Session.Keys.Count; i++)
{
string keyName = Session.Keys;
object keyValue = Session;
}

To set a value in a Session variable:

Session["VariableName"] = value;

To read a Session variable of int type:

int i = Int32.Parse(Session["VariableName"]

....and so on for others types.

HTH
 
'how to display all items in a user's session:

Dim keys As
System.Collections.Specialized.NameObjectCollectionBase.KeysCollection =
Session.Keys
Dim key As String
Dim sSessions As String

For Each key In keys
sSessions &= key.ToString & " - " & Session(key).ToString & "<br>"
Next key

If sSessions.Length = 0 Then
lblSession.Text = "No Active Sessions"
Else
lblSession.Text = sSessions
End If
 
Back
Top