asp实现统计访问量的代码
<%
dim count,path
count= 1
path = server.Mappath("count.txt")
Set fs=CreateObject("scripting.filesystemobject")
if(fs.FileExists(path))then
Set hs=fs.opentextfile(path)
count=hs.ReadLine
if session("iscount")="" then
session("iscount")="iscount"
count=count+1
end if
hs.close
Set hs=fs.opentextfile(path,2,true)
hs.writeline(count)
else
Set hs=fs.createtextfile(path)
hs.writeline(1)
end if
response.write "您是第"&count&"位访问者!"
hs.close
set fs=nothing
%>
<% dim count,path count= 1 path = server.Mappath("count.txt") Set fs=CreateObject("scripting.filesystemobject") if(fs.FileExists(path))then Set hs=fs.opentextfile(path) count=hs.ReadLine if session("iscount")="" then session("iscount")="iscount" count=count+1 end if hs.close Set hs=fs.opentextfile(path,2,true) hs.writeline(count) else Set hs=fs.createtextfile(path) hs.writeline(1) end if response.write "您是第"&count&"位访问者!" hs.close set fs=nothing %>
非每次刷新都记录!