?
Solved

Tracking Visits to my Web Site

Posted on 1997-06-24
2
Medium Priority
?
195 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 90 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

839 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