| Author: Meetu Choudhary 16 Oct 2008 | Member Level: Gold | Rating: Points: 3 |
for this you have to create an application variable which will be initialized with zero at the start of day and when a new session starts increment it by one and any moment when you read this you will get the total no of visits for the site at that particular moment for the day
hope it helps you
== Thanks and Regards Meetu Choudhary
|
| Author: Athira Appukuttan 16 Oct 2008 | Member Level: Diamond | Rating: Points: -20 |
Try like this Global.asax:
Sub Application_OnStart 'initialize variable Application("visitors_online") = 0 End Sub Sub Application_OnEnd
End Sub
Sub Session_OnStart Session.Timeout = 20 '20 minute timeout Application.Lock Application("visitors_online") = Application("visitors_online") + 1 Application.Unlock End Sub Sub Session_OnEnd Application.Lock Application("visitors_online") = Application("visitors_online") - 1 Application.Unlock End Sub
On line users: <%=Application("visitors_online")%>
|
| Author: Nagarajan 16 Oct 2008 | Member Level: Gold | Rating: Points: 2 |
A small change to appukuttan's code,
As you need dially visit count, the application variable has to be reset at the end of the day, else when you see the count next day morning, it get appended to previous day count.
Sub Application_OnStart 'initialize variable Application("visitors_online") = 0 Application("currentDate") = Datetime.Today End Sub Sub Application_OnEnd
End Sub
Sub Session_OnStart Session.Timeout = 20 '20 minute timeout Application.Lock if Application("currentDate") <> DateTime.Today Application("visitors_online") = 0; Application("currentDate") = DateTime.Today end if Application("visitors_online") = Application("visitors_online") + 1 Application.Unlock End Sub
Sub Session_OnEnd Application.Lock Application("visitors_online") = Application("visitors_online") - 1 Application.Unlock End Sub
Just added a Date value to Application to kepp track of the end of day.
Hope this helps Happy Coder.
|