我的网站上需要判断一个用户是否已经登录,以前用Session来保存用户信息,但用Window.Open方法的新窗口时常会发生丢失Session的现象。现在用Application来解决,在Application存放用户信息。
<%
Dim SID
if Request.QueryString("sid") = "" then
Dim StaffInfo(3)
StaffInfo(0) = "6500"
StaffInfo(1) = "孔乙已"
StaffInfo(2) = "127.0.0.1"
StaffInfo(3) = Session.SessionID
SID = Session.SessionID
Application.Lock()
Application(SID) = StaffInfo
Application.UnLock()
%>
<SCRIPT Labguage="Javascript">
var left = (screen.width-750)/2;
var windowinfo = "toolbar=no,resizable=no,scrollbars=no,width=750,height=500,top=20 ,left=" + left;
window.open("default.asp?sid=<%=Session.SessionID%>",null,windowinfo);
</SCRIPT>
<%
else
SID = Request.QueryString("sid")
end if
CurStaffInfo = Application(SID)
Response.Write(CurStaffInfo(0)&"<BR>")
Response.Write(CurStaffInfo(1)&"<BR>")
Response.Write(CurStaffInfo(2)&"<BR>")
Response.Write(CurStaffInfo(3)&"<BR>")
Response.End()
%>
<%
Dim SID
if Request.QueryString("sid") = "" then
Dim StaffInfo(3)
StaffInfo(0) = "6500"
StaffInfo(1) = "孔乙已"
StaffInfo(2) = "127.0.0.1"
StaffInfo(3) = Session.SessionID
SID = Session.SessionID
Application.Lock()
Application(SID) = StaffInfo
Application.UnLock()
%>
<SCRIPT Labguage="Javascript">
var left = (screen.width-750)/2;
var windowinfo = "toolbar=no,resizable=no,scrollbars=no,width=750,height=500,top=20 ,left=" + left;
window.open("default.asp?sid=<%=Session.SessionID%>",null,windowinfo);
</SCRIPT>
<%
else
SID = Request.QueryString("sid")
end if
CurStaffInfo = Application(SID)
Response.Write(CurStaffInfo(0)&"<BR>")
Response.Write(CurStaffInfo(1)&"<BR>")
Response.Write(CurStaffInfo(2)&"<BR>")
Response.Write(CurStaffInfo(3)&"<BR>")
Response.End()
%>