Solved

Tracking Visits to my Web Site

Posted on 1997-06-24
2
190 Views
Last Modified: 2013-12-25
A) The current web site I am working on I created using Microsoft Visual Interdev

B) the problem > I track the number of visits to the web site in a text file.  I use the Session_OnStart routine in global.asa via VBSCRIPT.

The process is to 1) load the text file in to get the count, 2) close that file, 3) re-create the file writing the new total of visits.

Finally, my question> What happens if two people access the file at the same time?  How can I protect from any possible file problems?
0
Comment
Question by:MLHAMMEL
2 Comments
 
LVL 5

Accepted Solution

by:
icd earned 30 total points
ID: 1828532
If two people access at the 'same time' then the worst that can happen is that one visit will not be counted. Imagine the counter having the value 100

Visitor A opens the file, reads 100
Visitor B opens the file, reads 100
Visitor A writes the value 101
Visitor B writes the value 101

With more complex data manipulations it can cause inconsitancies between dependent data which can cause your database to become corrupted.

The normal way of locking in perl is to use the 'flock' command. I have not used VBSCRIPT but there is likely to be a similar method in that language. Do a search for 'lock'. To do an update you first obtain the lock, make the read, increment it, write the file back again and then free the lock. Another process wanting to do an update will have to wait for the lock to become available.

On my own web site I don't bother with file locking in this type of case since the data is fairly inaccurate anyway. So long as it does not corrupt the data I don't mind.

0
 

Author Comment

by:MLHAMMEL
ID: 1828533
I did some research and you are right about the LOCK command.  I am using Application.Lock, Application.Unlock

Good anwser.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Could you point how to deal with this kind of PHP notation? 7 113
change home folder path 4 56
Where do I learn ES6? 3 78
exchange ,script 10 52
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question