欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何限制同一用戶名同時登陸

 更新時間:2006年06月27日 00:00:00   作者:  
這個問題我的辦法是,用戶有個活躍時間間隔問題。超過這個活躍時間間隔的則可以認為是離線,后者可以登陸 ,如果無后者登陸,但并不是說前者就需要重新登陸了。因為他的session還在的。只能是這個時間設置的越小越精確,也是不能做到絕對的。
代碼貼出來給樓主參考下。
Function CheckOnline()

	DIM IP,rsPrv,Sql,PrvDbState
	PrvDbState = False
	If DBSTATE = False Then
		DbOpen()
		PrvDbState = True
	End If
	Set rsPrv=Server.CreateObject("ADODB.Recordset")
	If Session("UserName") = "" then
		Sql="select * from [Online] where SessionID='"& Session.Sessionid &"'"
		rsPrv.Open Sql,Conn,1,3
		If rsPrv.Eof then
			rsPrv.AddNew
			rsPrv("SessionID") = Session.SessionID
			rsPrv("GroupChargeLv") = -1
			rsPrv("LastActTime") = Now()
			rsPrv("UserIP") = GetIP
			rsPrv("OnLineTime") = 0
			rsPrv("UserWhere") = Request.ServerVariables("HTTP_REFERER")
		Else
			rsPrv("UserWhere") = Request.ServerVariables("HTTP_REFERER")
			rsPrv("OnLineTime") = rsPrv("OnLineTime") + DateDiff("n",rsPrv("LastActTime"),Now())
			rsPrv("LastActTime") = Now()
		End If
		rsPrv.Update
		rsPrv.Close()
		'response.Write "notlogin"
	Else
		'response.Write "logined"
		Sql="select * from [Online] where UserName='"& Session("UserName") &"'"
		rsPrv.Open sql,Conn,1,3
		If rsPrv.Eof then
			rsPrv.AddNew
			rsPrv("SessionID") = Session.SessionID
			rsPrv("UserName") = Session("UserName")
			rsPrv("GroupChargeLv") = Session("GroupChargeLv")
			rsPrv("LastActTime") = Now()
			rsPrv("OnLineTime") = 0
			rsPrv("UserIP")= GetIP
			rsPrv("UserWhere") = Request.ServerVariables("HTTP_REFERER")
		Else
			If rsPrv("SessionID") <> Session.SessionID And Application("LoginSet")(1) = False Then
				InfoTo "LoginOut.asp","該帳戶已在其他地方登陸,網(wǎng)站設置1個ID只能有1個登陸\n你可以稍候嘗試登陸。"
				Response.End()
			End If
			rsPrv("UserWhere") = Request.ServerVariables("HTTP_REFERER")
			rsPrv("OnLineTime") = rsPrv("OnLineTime") + DateDiff("n",rsPrv("LastActTime"),Now())
			rsPrv("LastActTime")=Now() 
		End If
		rsPrv.Update
		rsPrv.Close()
	End If
	Set rsPrv = Nothing
	
	If DateDiff("s",Application("OnLineLastDelete"),Now()) > Int(Application("DELETEONLINEDIFF")) Then
		Application.Lock()
			Application("OnLineLastDelete") = now
		Application.UnLock()
		Conn.ExeCute("delete from [Online] where datedIff('s',LastActTime,Now())>"&	Int(Application("CHECKONLINEDIFF") &"")) '刪除x秒沒有活動的訪客
	End If
	
	If PrvDbState = True Then DbClose()
	
End Function

相關文章

最新評論