private System.Web.SessionState.SessionStateItemCollection getActiveSession(string UserID)
{
object obj = typeof(HttpRuntime).GetProperty("CacheInternal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null, null);
object[] obj2 = (object[])obj.GetType().GetField("_caches", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(obj);
for (int i = 0; i < obj2.Length; i++)
{
System.Collections.Hashtable c2 = (System.Collections.Hashtable)obj2[i].GetType().GetField("_entries", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(obj2[i]);
foreach (System.Collections.DictionaryEntry entry in c2)
{
object o1 = entry.Value.GetType().GetProperty("Value", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(entry.Value, null);
if (o1.GetType().ToString() == "System.Web.SessionState.InProcSessionState")
{
System.Web.SessionState.SessionStateItemCollection sess = (System.Web.SessionState.SessionStateItemCollection)o1.GetType().GetField("_sessionItems", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(o1);
if (sess != null)
{
if (sess["UserId"] != null && sess["UserId"].ToString() == UserID)
{
return sess;
}
}
}
}
}
return null;
}