|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

May 14th, 2006, 05:25 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|

May 14th, 2006, 10:38 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 14th, 2006, 01:35 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I need a code sample!
|

May 14th, 2006, 01:41 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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)
|

May 15th, 2006, 10:01 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 23rd, 2006, 04:58 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
woodyZ how can I place that code in global.asa
can you give an example?
|

May 23rd, 2006, 11:00 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is 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 08:29 AM |
| users online.. |
ruhin |
Beginning PHP |
0 |
February 9th, 2005 01:58 PM |
| Get Value from online page |
qadeerahmad |
General .NET |
1 |
December 4th, 2004 12:00 PM |
| Online Updation |
qazi_nomi |
Classic ASP Basics |
12 |
September 24th, 2004 08:26 PM |
| Online Payment |
eapsokha |
Classic ASP Professional |
3 |
August 31st, 2004 01:42 AM |
|
 |