IP Address | Access to |IP address it is necessary for an administrator of a Web site to have IP records for visitors. By recording the IP of the visitor, it provides important information for the traffic statistics of the website, the distribution of the visitor source area, and the tracing of the illegal visitors.
Before compiling the program, we should first grasp a few points.
1, obtain the client IP address statement: Request.ServerVariables ("REMOTE_ADDR");
2, ASP statement written Cookies:Response.Cookies ("Cookiesname"), read out cookies:Request.Cookies ("Cookiesname");
3, SFO of writing;
The following are code and comments.
[Code]: If Request.Cookies ("visited") <> "True" Then ' determines whether the initial access
Ipfileaddr=server.mappath ("Visited.txt") ' Locate record IP text file
Getip=request.servervariables ("remote_addr") ' Take client IP address
Set Ipfs=server.createobject ("Scripting.FileSystemObject") ' establishes the FSO object
Set Ipfile=ipfs.opentextfile (ipfileaddr,8) ' To open a text file as a way to add
Ipfile.write (getip& "") ' Write to IP address
Ipfile.writeline (now ()) ' Write record time
Ipfile.close ' Close the FSO object
Response.Cookies ("visited") = "true" to set Client access status to True
End If
In the above code, by writing cookies to the client, you can prevent (but not complete) the user from writing the data to the file again when the page is refreshed, provided that the client opens the cookies.
The code provided in this article can be independent of an ASP document, and then use include nesting on pages that need to record IP addresses.