Solved

Tracking Visits to my Web Site

Posted on 1997-06-24
2
189 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

770 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