Research on the number of online people in the ASP forum

zhaozj2021-02-12  198

The method of self-feeling can be more accurately statistically online. Of course, there must be a place where you have a deficiency, I hope that the teachers will correct it.

Special Note:

This forum login is logged in using the username and obtains the user nickname after logging in. The entire website does not display the username, I want to be safe at all, so there is a nickname and username.

1. The establishment of the database table table name is ONLINE to record the session.Session IDName 'for each access to each access is recorded as a visit. Online 'If it is a login user name of the member of the member 1 DateTime', the visitors are empty. IP 'record access to login IP

Head.asp 'writes an online number to the database table, which must be searched to each of them used to browse the ASP page. <% set = server.createObject ("adoDb.recordset") IF session ("username") = "" THEN determines that the user does not log in to sql = "select * from online where id = '" & session.SessionID & "'" determination Whether this sessionID exists in the database table .rs.open SQL, CONN, 1, 3IF RS.EOF TEN 'visitors first browse RS.ADDNEWRS ("ID") = session.SessionIDRS ("Name") = "Visitor" RS ("online") = 0 '0 indicates that the user is not logged in, it is a tourist identity RS ("DateTime") = now () userip = request.servervariables ("http_x_forwarded_for") if userip = "" "" "" "" ") = request.servervariables "Remote_addr") End IF RS ("IP") = USERIPELSE 'Visitor Non-first browsing RS ("DateTime") = now ()' Update activity time uUPDATERS.CLOSEEND IFELSESQL = "SELECT * FROM online where id = '"& session.SessionID &"' or admin = '"& session (" UserName "&"' "determining the sessionID or username record existing data tables. RS.Open SQL, CONN, 1, 3IF RS.EOF THENRS.Addnew 'member enters the website for the first time (may log in directly from the website home page). RS ("ID") = session.SessionIDRS ("name") = session ("show") 'write user nickname RS ("username") = session ("username")' Write to log in User name RS ("Online) ") = 1 'indicates that the user has already logged in and is the member identity RS (" DateTime ") = now ()' Set the current system time to the user's login time userip = request.servervariables (" http_x_forwarded_forward_for ") if userip =" "" Userip = Request.serverVariables ("remote_addr") end if xi = useripelse // Member non-first browsing website, visitors log in to the website.

转载请注明原文地址:https://www.9cbs.com/read-7696.html

New Post(0)