Do you sometimes want to know what people visit your site, what time, IP address, and so on. Now I'm going to
Let us elaborate. This example uses a text file to write the user's information to create a logfile.asp
At the top of each ASP's page <!--#Include file= "logfile.asp"--> when someone comes to visit you
Site Logfile.asp automatically writes his information to LogFile.txt, if the relevant URL is the same
Write to File
File:LogFile.asp
<%
Dim validentry ' Log variable
' The ' This ' log is valid
Validentry = True
' If session Variable ' LogIn ' isn't ' empty
' That's mean this person has already been logged
' Then set Validlog to False
If Not IsEmpty (session ("LogIn")) then Validentry = False
' Here you can add different restriction
' If ' refering URL is from same site
' Don ' t write to log file
If Left (Request.ServerVariables ("Http_referer"), 17)
= "Http://devasp.com" Then
Validentry = False
End If
If Left (Request.ServerVariables ("Http_referer"), 21)
= "Http://www.devasp.com" Then
Validentry = False
End If
' Now if validentry are True then enter to log file
If Validentry Then
Const ForAppending = 8
Const Create = True
Dim FSO
DIM TS
DIM myFileName
Dim Strlog
myFileName = Server.MapPath ("MyLogFile.txt")
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Set TS = FSO. OpenTextFile (myFileName, ForAppending, Create)
' Store all required values in Strlog
Strlog = "<br><P><B>" & Now & "</B>"
Strlog = Strlog & Request.ServerVariables ("REMOTE_ADDR") & ""
Strlog = Strlog & Request.ServerVariables ("Http_referer") & ""
Strlog = Strlog & Request.ServerVariables ("Http_user_agent") & "<BR>"
' Write current information to Log Text File.
Ts.write Strlog
Ts. Writeline ""
' Create a session varialbe to check next time for Validentry
Session ("LogIn") = "yes"
Set TS = Nothing
Set FSO = Nothing
End If
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.