Jump to content

Server Components


n.nsivakumar

Recommended Posts

Hi guysIam Siva new to this forum and recently i faced a problem in PageCounter component, which is used to count the number of times the webpage has been opened. But when i shutdown the server at pagecounter value of 20 after restarting it will not continue from 21 instead it will start from 1.But i have read that it can store the values in some textfile and registered in the registry. But it cannot happen to me.Provide a technical support if u can.Siva. :)

Link to comment
Share on other sites

Hi Siva,You should create a .txt file called, for e.g., counter.txt and place it in the adequate root directory. In this file you only should write the number zero (0). Then use this code to increase the number contained in the file :

' Here you just open the conter.txt file and read the number... Set FS=Server.CreateObject("Scripting.FileSystemObject")Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 1, False)fcount=RS.ReadLineRS.Close' You increase the number...fcount=fcount+1' You insert the new number in your conter.txt file ...Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 2, False)RS.Write fcountRS.CloseSet RS=NothingSet FS=Nothing

You can also use some cookies or a session object to prevent a user to increase your counter more than once on the same day.This helps? :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...