I think this might be an IIS setting as the code works fine on another server. So that leads me to what should IIS be set at? I've never had a problem with the default before. I've got this set as an application with read ability.
Book:Beginning Dreamweaver MX
Page: 327
Here we create a sub and a function and place it into an include file.
The sub checks the cookie for new or returning and gets the URL using the servervariable.
Code:
Sub SetFirstVisitedPage ()
Dim sPageName
sPageName = Request.ServerVariables("URL")
If Len(Request.Cookies("CheckFirstPage")) = 0 Then
If Len(Request.Cookies("RevisitingUser")) = 0 Then
' New user
Application("Page_New_" & sPageName) = _
Application("Page_New_" & sPageName) + 1
Else
' Revisiting user
Application("Page_Revisit_" & sPageName) = _
Application("Page_Revisit_" & sPageName) + 1
End If
Response.Cookies("CheckFirstPage") = "Done"
Response.Cookies("RevisitingUser") = "Yes"
Response.Cookies("RevisitingUser").Expires = Date() + 30
End If
End Sub
Next we have a function that return a result. This function combines takes the name or the URL and the number of visits and combine them into a variable named "GetFirstVisitedPage". See last line of function.
Code:
Function GetFirstVisitedPage(ByVal bNewUsers)
Dim iMaxHits
Dim sAppVar
Dim sFirstVisitedPage
iMaxhits = 0
For Each sAppVar in Application.Contents()
If Left(sAppVar, 5) = "Page_" Then
If bNewUsers = True then
If Left(sAppVar, 9) = "Page_New_" Then
If CInt(Application(sAppVar)) > iMaxHits Then
iMaxHits = Application(sAppVar)
sFirstVisitedPage = Right(sAppVar, Len(sAppVar) - 9)
End If
End If
Else
If Left(sAppVar, 13) = "Page_Revisit_" Then
If CInt(Application(sAppVar)) > iMaxHits Then
iMaxHits = Application(sAppVar)
sFirstVisitedPage = Right(sAppVar, Len(sAppVar) - 13)
End If
End If
End If
End If
Next
GetFirstVisitedPage = sFirstVisitedPage & " with " & iMaxHits & " hits "
End Function
The result of this should allow me to read the following to a page and get the page location/url and the number of hits for that page. However it will only give me the number of hits.
Code:
The most popular first page for new users is:
<%= GetFirstVisitedPage (True) %>
<br>
The most popular first page for returning visitors is:
<%= GetFirstVisitedPage (False) %>