日期:2014-05-18  浏览次数:20534 次

怎么根据session id获得session的值呢
怎么根据session id获得session的值呢

------解决方案--------------------
思路是这样的:
Sessions are sandboxed, and can't access one another. However,
they can all access Application Scope. So Application is wehre you can put
some reference to a Session. You still can't actually access the Session
there, though.

Perhaps the best thing would be to put a Collection into the Application
Cache, and emulate Sessions there. The Session_Start method could create a
member of that Collection in the Application, and identify it with the
unique SessionID that the Session generates, which could then be used to
access the element in the Collection that "stands for" that Session.


可以参考下面的代码.在Session_Start中将Session记录到全局变量中.
How to get detailed info about all online visitors that are currently browsing your ASP.NET website?
http://www.aspdotnetfaq.com/Faq/How-to-get-detailed-info-about-all-online-visitors-that-are-currently-browsing-your-ASP-NET-website.aspx
------解决方案--------------------
string s = Session["SessionID"].ToString();

Type x = (Type)Session["SessionID"];
其中Type为SessionID中记录的数据的类型