Friday, July 30, 2010

How to: List all Session variables?

This is how we can get list of all session variables using c#.

for (int i = 0; i < Session.Contents.Count; i++)
{
    Response.Write(Session.Keys[i] + " - " + Session[i] + "<br />");
}
foreach (string key in Session.Keys)
{
    Response.Write(key + " - " + Session[key] + "<br />");
}

Either of them can get you all session details.

No comments:

Post a Comment