Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hit Counter for links on a page

Status
Not open for further replies.

NickyJay

Programmer
Joined
Sep 1, 2003
Messages
217
Location
GB
Hi All,

Happy New Year to everyone :)

I have been asked if i can set up a hit counter for an internal site that stores links to various hr manual documents. Basically i want to record the number of times the document is viewed and possibly the user's id from their windos login - is any of this possible?

I thought about having an extra table in my database with the foreign key of the document and a counter field to be updated each time the document link is clicked, but how would i get a query to update this field?

also, in other databases i have been able to capture the users id from windows - Environ("username") in access - can i do this with Coldfusion, do i need to be looking at cookies?

any suggestions are welcome :)

thanks!
 
While this is normally done by log analysis programs, you could roll your own.

The link would actually be to a processing page, e.g.

"hitcounter.cfm?doc=doclibrarypath/TheDocumentName.doc"

Hitcounter.cfm would contain a CFQUERY to insert a record of the request and the user (which BTW is CGI.AUTH_USER in authenticated and protected environments) and then CFLOCATION to the document:

<cfquery ....>
INSERT INTO Logtable
(user,doc)
VALUES
('#CGI.AUTH_USER#','#url.doc#')
</cfquery>
<CFLOCATION URL="#url.doc#">

HTH,

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
If using Active Directory you can pull the Windows login ID using LDAP. I have the code for CF6 but CF7 has tags that allow easy LDAP interaction.

Cheers,

Bluetone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top