<% Dim blnValidEntry ' Log variable ' First set that this log is valid blnValidEntry = True ' If Session Variable "LogIn" is not empty ' that mean this person has already been logged ' then set blnValidEntry to False If not IsEmpty(Session("LogIn")) then blnValidEntry = False ' Here you can add different restriction ' If the refering url is from same site ' then there is no need to write to log file If Left(Request.ServerVariables("HTTP_REFERER"), 17)="http://devasp.com" Then blnValidEntry = False End If If Left(Request.ServerVariables("HTTP_REFERER"), 21)="http://www.devasp.com" Then blnValidEntry = False End If ' Now if blnValidEntry is True then enter to log file If blnValidEntry 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 the required information in a string Called strLog strLog = "

" & NOW() & " " strLog = strLog & Request.ServerVariables("REMOTE_ADDR") & " " strLog = strLog & Request.ServerVariables("HTTP_REFERER") & " " strLog = strLog & Request.ServerVariables("HTTP_USER_AGENT") & "
" ' Write current information to Log Text File. TS.write strLog TS.Writeline "" ' Now Create a session varialbe to check next time for ValidEntry Session("LogIn") = "yes" Set TS = Nothing Set FSO = Nothing End If %>