Solved

Modifying Refresh ...

Posted on 2002-06-18
29
311 Views
Last Modified: 2012-08-14
Hi experts

Well to explain my problem in short , i have an application which is shared by different branches of an organsation all over the worlkd. now the client's requiremnt is that there should be login alert kind of thing , like we get in msn / yahoo messengers.. that is a pop up as soon as some one has logged in / or even logged out

how can i maintan this kind os a system in asp. please note , i want to use only asp , as my entire thing has been created here and this is the plateform i'm most comfortable in.

Adit
0
Comment
Question by:adit_2k
  • 15
  • 5
  • 5
  • +3
29 Comments
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
sorry to be posting a "wrong subject" for the question. i was lost in someother problem of mine, which i will ask a little later once this thing gets over. i'm again sorry for the wrong indicator
0
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
you know that asp displays html pages (for the web) that relies on the http protocole that is session-less and connection-less, so you can do it only when a user logs in you log a record for it in the database.. and when a supervisor..etc.. refresh the page he can only get the popups (you here set a flag that the popup was shown).. read the comment below that is similar to what you need (the comment was about counting active users)

to log the users use the session on start..

The only problem you might encounter here is that On IIS4 (and in minor cases on IIS5) Session on end never gets fired.. thus the count doesn't get decreased..
Now to solve this matter you can instead store user session IDs in databases and the timestamp when you stored them in the session onstart event.. you only count the records that have timestamps younger than your session time (default is 20) .. also you can include in the session on start a code to delete records older than 20 minutes..

rgrds
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
silvers5 , i knew that i will not be able to match what the messengers do because of browser / html limits. i also knew i wud have to do all this thru pop-ups only

now what i wanted was that a pop up comes whenever a user is online . also when a user goes offline , he shd disappear from list of online users on the main page header.

i have never used session objects too much in my limited asp experience . therefore soe code help wud me damn helpful
thanks
0
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
search in www.aspin.com for count users, you will have similar code..
in your pages you will need to loop thru the record and show the active users.. you can also let the page refresh every x seconds by adding a refresh meta tag ..
0
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
http://www.aspin.com/func/search?tree=aspin&qry=count+users&cat=

there's an example stating "who are those active users" and I guess it's what you want
0
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
now in your specific case you remove the action in the session onstart.. you log to the database instead when the user logs in.. you remove it in the same above way..
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
ok.. i'm going there
0
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
don't forget to come back later ;o)
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Doing the "log out" is going to be tough... even with the global.asa method.

What if the user simply closes the browser?
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
i did not get time to try the code last eve. but today i'm free , and shd be able to implement that.

yes mgfranz's comment is cery suitable. what if the user simply closes the browser . (i always wanted him to do that)

adit
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
silvers5,,, script with session on_starts and session_onends is really buggy.. u r right the session_onend doesnt ever get fired up.

i logged into to databasse .. fine till there as i set of a flag in there.. now how do i logoff , if the person just closes the browser, and not the logout button. i get stuck there.

pls help
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
well i'm stuck and nobody is responding...
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
ok.. now.. can anyone tell me a clue abt logout. i have to force the user to click logout and not just shut off the browser. is this even possible in IE
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
hey... no comments here.... shall i close/delete the q
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Expert Comment

by:albay
Comment Utility
0
 
LVL 4

Expert Comment

by:albay
Comment Utility
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Please try to cut/paste your code in smaller increments, perhaps it is too long.

Also don't have a blank in the first character field.

If you are pasting text from a Word Processor, paste it to Notepad first to eliminate the formatting which may cause you this "no text" problem.

Moondancer - EE Moderator
0
 
LVL 4

Expert Comment

by:albay
Comment Utility
this is what you want, i hope.

you have to use global.asa file..
first of all declare a ADODB.RecordSet  in your global.asa file and on application_start, create this object. i will write whole global.asa file that you need soon.. be patient. :)))

**************************
when user log into the system. save the info about user by passing necessary parameters to this function.

Sub Online(Name)
     Session("Start") = Now()

     If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast

     rstActiveUsers.AddNew
     
     rstActiveUsers.Fields("id").Value = Session.SessionID
     
     rstActiveUsers.Fields("ip").Value = Request.ServerVariables("REMOTE_HOST")
     
     rstActiveUsers.Fields("browser").Value = Request.ServerVariables("HTTP_USER_AGENT")
     
     rstActiveUsers.Fields("started").Value = Now()

     rstActiveUsers.Fields("user").Value = Name

     rstActiveUsers.Update
End Sub

**************************
and when user clicked the logout button use Session.Abandon this operation will fire the Session_OnEnd event handler and here is the session_onend handler in global.asa file.

Sub Session_OnEnd()
     Const adSearchForward = 1
     Const adBookmarkFirst = 1
     Const adAffectCurrent = 1


     rstActiveUsers.Find "id = " & Session.SessionID, _
          0, adSearchForward, adBookmarkFirst
     

     If Not rstActiveUsers.EOF Then
          rstActiveUsers.Delete adAffectCurrent
     End If
End Sub

********************
and define a Session.TimeOut value in Session_OnStart handler in global.asa file. by doing that, you will fire Session_OnEnd if user closes the Explorer without clicking logout button.

Sub Session_OnStart()
     ' Session zaman a?ymyny 3 dakika yap
     Session.Timeout = 3
End Sub

******************this is the global.asa file below*************

<object runat="Server" scope="Application" id="rstActiveUsers" progid="ADODB.Recordset">
</object>

<script language="VBScript" runat="Server">

Sub Application_OnStart()
     Const adInteger = 3
     Const adVarChar = 200
     Const adDate = 7
     
     rstActiveUsers.Fields.Append "id", adInteger
     rstActiveUsers.Fields.Append "ip", adVarChar, 15
     rstActiveUsers.Fields.Append "browser", adVarChar, 255
     rstActiveUsers.Fields.Append "started", adDate
     rstActiveUsers.Fields.Append "user", adVarChar, 50

     rstActiveUsers.Open
End Sub

Sub Session_OnStart()
     ' Session zaman a?ymyny 3 dakika yap
     Session.Timeout = 3
End Sub

Sub Session_OnEnd()
     Const adSearchForward = 1
     Const adBookmarkFirst = 1
     Const adAffectCurrent = 1


     rstActiveUsers.Find "id = " & Session.SessionID, _
          0, adSearchForward, adBookmarkFirst
     

     If Not rstActiveUsers.EOF Then
          rstActiveUsers.Delete adAffectCurrent
     End If
End Sub

Sub Application_OnEnd()
     rstActiveUsers.Close
End Sub
</script>

****************************************

when you want to see online users, use this code.
<%
If rstActiveUsers.RecordCount > 0 Then
     rstActiveUsers.MoveFirst

     Response.Write "<table border=""1"">" & vbCrLf

     Response.Write " <thead>" & vbCrLf
     Response.Write "  <th>Session Id</td>" & vbCrLf
     Response.Write "  <th>IP Address</th>" & vbCrLf
     Response.Write "  <th>Browser Info</th>" & vbCrLf
     Response.Write "  <th>Start Time</th>" & vbCrLf
     Response.Write "  <th>User Name</th>" & vbCrLf
     Response.Write " </thead>" & vbCrLf

     Do While Not rstActiveUsers.EOF

          Response.Write " <tr>" & vbCrLf
          Response.Write "  <td>" & rstActiveUsers.Fields("id").Value & "</td>" & vbCrLf
          Response.Write "  <td>" & rstActiveUsers.Fields("ip").Value & "</td>" & vbCrLf
          Response.Write "  <td>" & rstActiveUsers.Fields("browser").Value & "</td>" & vbCrLf
          Response.Write "  <td>" & rstActiveUsers.Fields("started").Value & "</td>" & vbCrLf
          Response.Write "  <td>" & rstActiveUsers.Fields("user").Value & "</td>" & vbCrLf
          Response.Write " </tr>" & vbCrLf
         
          rstActiveUsers.MoveNext
     Loop
     Response.Write "</table>" & vbCrLf

End If
%>
*********************

best regards,
Orhan
0
 
LVL 4

Expert Comment

by:albay
Comment Utility
thank you very much Moondancer.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
My pleasure, happy it helped you post this and sorry you had this inconvenience.  Thank you for your help here.
:) Moondancer - EE Moderator
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
albay... i just got back from the mountains yesterday. will definitely take a look at ur comment soon and get back
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
Orhan , i checked your code (in local environment) and found some problemin it which i cud not address . i will try to report them here :-

1.after i log in a user , it gives me the online user name just fine . now when i log in another user from the same machine the previous user also stays logically logged , then the online user status just shows the 2nd one to be online and removes the ist one from online user list.

now if i logoff any one user (session.abandon) , and then refrwsh the window of online user list , it give the foll error

Microsoft Cursor Engine error '80040e23'
Row handle referred to a deleted row or a row marked for deletion.
/carlton/sampling/newmessages.asp, line 67

Why it never shows 2 online users at a particular time ?
Why is this error coming after logging out one user

also , can u explain when the user simply closes the brower , how wud the session close after 3 min with session.expire . wont it expire the session anyway even if the window is open / and the user has not closed the browser or/and logged off
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
also i have a rented space on my isp's server . wont placing global.asa in it be a problem. where will i put it in ? or wud i have to ask the administrator to do it for me .isn't global.asa COMMON for the entire server or can different sites have their own global.asas for themselves

Adit
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
Also if i try to response.write rstActiveUsers.Recorcount , they keep on increasing even if i logoff the users everytime . why is this happening
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
yes thats what i feared .. .after 3 minutes (session.expire setting) , if i again go to the page showing list of active users , i get

Microsoft Cursor Engine error '80040e23'
Row handle referred to a deleted row or a row marked for deletion.
/carlton/sampling/newmessages.asp, line 67

that line btw is :-
Response.Write rstActiveUsers.Fields("user").value

so there again is the error. pls do u have a turnaround to all these problems
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
no further help... !!!....
0
 
LVL 4

Expert Comment

by:albay
Comment Utility
i get the same error message.. but when i refresh the page, it loads all user info. i do not know why.

and i learned that Session_OnEnd might be fired as soon as user closes the page. this can be done with some Server settings but i do not know. i am so sorry.
0
 
LVL 1

Author Comment

by:adit_2k
Comment Utility
no probsalbay... i might have to close the q. incase i dont get any more comments soon
thanx for your help
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
Points refunded and placed in PAQ

Computer101
E-E Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now