實現(xiàn)這個功能可有兩種方式:
1。application
用application對象:如果做的是大型社區(qū),可能要為每個登陸id生成一個appliaction,這樣做雖然程序上設(shè)計會簡單些但登陸用戶過多及其耗費服務器資源,這里決不提倡,因為appliaction對象在用戶登陸時生成很容易, 但是要做到真正的隨著用戶退出系統(tǒng)完全釋放,到目前還沒看到更好的方法~
<%
.....取用戶名username.....
if Application(username)<>"" then
response.write "該用戶已經(jīng)登錄"
response.end
end if
Application(username)=username ''存入該用戶的用戶名
%>
在global文件中加上session onend事件,下線時Application("isuserlogin")=false
此外還要檢測是否吊線,有專門的辦法,是server對象里的某項
(參: http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=815)
2。數(shù)據(jù)庫+asp
做起來可能會復雜些,但是適合有大量登陸用戶的系統(tǒng)。
首先為用戶建立數(shù)據(jù)庫-用access新建一個onlyTOL8.mdb
數(shù)據(jù)表1: users 存放用戶注冊資料
下設(shè)數(shù)據(jù)表:uID(自動編號) userName(字符型) userPass(字符型)
數(shù)據(jù)表2: onlyLogin 存放用戶臨時登陸信息
下設(shè)數(shù)據(jù)表: OLname(字符型) OLtime(日期型) OLip(字符型)
數(shù)據(jù)庫建好后直接向users表中手動添加數(shù)據(jù) userName表添加TOL8,userPass表里添加111,
下面來做用戶登陸界面,復制下面代碼存成onlyLogin.asp文件。
禁止同一賬號不同地區(qū)同時登陸
完成后在新建一個loginCONN.asp文件復制下面的代碼保存用于連接數(shù)據(jù)庫
<%
Dim CONN_TOL8
Dim Conn_T
Dim mmdd
mmdd="onlyTOL8.mdb"
Set CONN_TOL8 = Server.CreateObject("ADODB.Connection")
Conn_T="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&mmdd&"")
on error resume next
CONN_TOL8.Open Conn_T %>
1。application
用application對象:如果做的是大型社區(qū),可能要為每個登陸id生成一個appliaction,這樣做雖然程序上設(shè)計會簡單些但登陸用戶過多及其耗費服務器資源,這里決不提倡,因為appliaction對象在用戶登陸時生成很容易, 但是要做到真正的隨著用戶退出系統(tǒng)完全釋放,到目前還沒看到更好的方法~
<%
.....取用戶名username.....
if Application(username)<>"" then
response.write "該用戶已經(jīng)登錄"
response.end
end if
Application(username)=username ''存入該用戶的用戶名
%>
在global文件中加上session onend事件,下線時Application("isuserlogin")=false
此外還要檢測是否吊線,有專門的辦法,是server對象里的某項
(參: http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=815)
2。數(shù)據(jù)庫+asp
做起來可能會復雜些,但是適合有大量登陸用戶的系統(tǒng)。
首先為用戶建立數(shù)據(jù)庫-用access新建一個onlyTOL8.mdb
數(shù)據(jù)表1: users 存放用戶注冊資料
下設(shè)數(shù)據(jù)表:uID(自動編號) userName(字符型) userPass(字符型)
數(shù)據(jù)表2: onlyLogin 存放用戶臨時登陸信息
下設(shè)數(shù)據(jù)表: OLname(字符型) OLtime(日期型) OLip(字符型)
數(shù)據(jù)庫建好后直接向users表中手動添加數(shù)據(jù) userName表添加TOL8,userPass表里添加111,
下面來做用戶登陸界面,復制下面代碼存成onlyLogin.asp文件。
完成后在新建一個loginCONN.asp文件復制下面的代碼保存用于連接數(shù)據(jù)庫
<%
Dim CONN_TOL8
Dim Conn_T
Dim mmdd
mmdd="onlyTOL8.mdb"
Set CONN_TOL8 = Server.CreateObject("ADODB.Connection")
Conn_T="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&mmdd&"")
on error resume next
CONN_TOL8.Open Conn_T %>