Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 14th, 2006, 04:25 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default who is online?

Hi,
I have designed a membership script.
it has also a last logon field which gets the date/time(now())
when user logs in.
now how can I write a code that shows which user is online at that time?
a user might login at 1 am but after a few hours this time remain in the db!


Reply With Quote
  #2 (permalink)  
Old May 14th, 2006, 09:38 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One way is to keep track of the users session.
In the global.asa file you can handle the event for Session_OnEnd. In that event handler you would place code that marks the users record in the database as being off-line, or to do whatever you need to change in your database (or whereever) that the user is no longer active in the systems.

Make sense?

Woody Z http://www.learntoprogramnow.com
Reply With Quote
  #3 (permalink)  
Old May 14th, 2006, 12:35 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I need a code sample!

Reply With Quote
  #4 (permalink)  
Old May 14th, 2006, 12:41 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there any way without global.asa
sth like this code StrOnlineTimedout = dateadd("n",-strtimeout*60,onlinedate)
that when a user logs on it shows him online until 1 hour(the period the session exipres)

Reply With Quote
  #5 (permalink)  
Old May 15th, 2006, 09:01 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well... what exactly would StrOnlineTimedout be used to do?
Where is it declared - in which asp file? It is just a variable - what code is going to use it, and what will it do with it?
Why not use the global.asa? Perhaps I am misunderstanding you.

Woody Z http://www.learntoprogramnow.com
Reply With Quote
  #6 (permalink)  
Old May 23rd, 2006, 03:58 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

woodyZ how can I place that code in global.asa
can you give an example?

Reply With Quote
  #7 (permalink)  
Old May 23rd, 2006, 10:00 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is a very simple example.

First, the global.asa


Code:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'This is a very simplistic  example.

Sub Application_OnStart
    ' Ths initializes the counter
    Application("ONLINE_COUNT") = 0
End Sub

Sub Session_OnStart
    ' Use whatever timeout you want.  This sets it to 1 minutes for test purposes
    ' so you can easily see the count go down as sessions are ended...
    Session.Timeout = 1

     ' By setting a session variable when we first start a session we make sure that
     '    a session is actually started.
     Session("STARTED") = Now    
     ' Increment that counter that keeps track of users with an active session
     Application.Lock
         Application("ONLINE_COUNT") = Application("ONLINE_COUNT") + 1
     Application.UnLock

End Sub

Sub Session_OnEnd
    ' Decrease the active visitors count when the session ends. 
    Application.Lock
        Application("ONLINE_COUNT") = Application("ONLINE_COUNT") - 1
    Application.UnLock
End Sub

</SCRIPT>
and now a simple page to demonstrate:
Code:
<%

' I named this page ShowCount.asp
function GetCount
    s = "The count is: " & Application("ONLINE_COUNT") & "<br/>"†††
    GetCount = s
end function

function GetSessionStart
    †GetSessionStart = "I signed on at: " & Session("STARTED") & "<br/>"
end function
%>


<html>
<head><title>Count Users Test</title></head>
<body>
    †<%=GetCount %>
    †<%=GetSessionStart %>    †
</body>
</html>
I found an example of what you want here:
http://www.asp101.com/articles/john/...ve_users_2.asp

Woody Z http://www.learntoprogramnow.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
users online vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 23rd, 2007 07:29 AM
users online.. ruhin Beginning PHP 0 February 9th, 2005 12:58 PM
Get Value from online page qadeerahmad General .NET 1 December 4th, 2004 11:00 AM
Online Updation qazi_nomi Classic ASP Basics 12 September 24th, 2004 07:26 PM
Online Payment eapsokha Classic ASP Professional 3 August 31st, 2004 12:42 AM



All times are GMT -4. The time now is 02:42 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.