Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 11th, 2001, 02:29 AM
bigbirdie bigbirdie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Toronto
Posts: 0 bigbirdie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Determining current users (on your server)

Hi ,

I am using the $ENV{"REMOTE_ADDR"} ...ie

{
$insertingvalues[1] = $ENV{"REMOTE_ADDR"}
<insert into mysql database log table>
}

to log ip addresses (in mysql) regarding remote users after they log in to my web site.

After much fruitless searching , i still don't know how to go about determining if that remote user is still logged in, meaning , their browser is still pointed at my web page (domain). What i want to do is automatically log (in mysql) when the user redirects or goes away from my site.

Any ideas on the tracking functionality ? (the mysql and ip i already have - just need to know if he or she is still there) and i dont feel like buying a script today.



Thanx again, folks

Reply With Quote
  #2  
Old April 11th, 2001, 06:45 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

<<
their browser is still pointed at my web page (domain). What i want to do is automatically log (in mysql) when the user redirects or goes away from my site.
>>


i think it wouldn't be that much easy becuase if client is not making any request to your server you can't update the db.May be you have to find out a way with client side(java script) programming to achive this.
__________________
SR -
webshiju.com
www.lizratechnologies.com

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #3  
Old April 11th, 2001, 02:13 PM
bigbirdie bigbirdie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Toronto
Posts: 0 bigbirdie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool user still there ?

Hey Shiju,

thanks for the respond. You have given me the basic idea, something whereby i would use javascript...

theoretically speaking here is some semicode... ie _>

<BODY BGCOLOR=#FFFFFF onLoad="window.setTimeout('updateuser();',30000);">
...then set the call up recursively...

<SCRIPT LANGUAGE="JavaScript">
function myfunc() {
// call mysql user table, and log the fact he/she is there

document.location.href = "http://myserver/mywebpage/cgi-bin/upate-user.pl?userstatus=loggedin"

window.setTimeout('updateuser();',30000);
}

to first set the timeout period, that would then
call a javascript function that would call a perl script that would call the database.

Thanx, i will go with this idea/ approach for now. I will post the results..

Reply With Quote
  #4  
Old April 11th, 2001, 02:19 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
what about a javascript onUnload?

not sure if that would work.

Reply With Quote
  #5  
Old April 11th, 2001, 02:40 PM
bigbirdie bigbirdie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Toronto
Posts: 0 bigbirdie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question user still there ?

Yes i just tried the unload() function, that works very well too (very good call), Mr. unobserved, this is probably the best solution so far. The only caveat , is that you must hold the user back (for 1 more page) , and tell them they have been logged out, i suppose this is the best way- so far.

Even better solution, would be less obtrusive or go undetected as the user is prevented from going straight to his/her new destination...

? Any ideas (ie use the unload() function and then redirect them to their original destination - me thinks thats not possible)

The other problem is that you have to put all this code in all your html and perl scripts (a lot of work) , on the client side, this is probably the only way to do this, but if there was a server side solution (ie 1 script), that would be best - again maybe not possible.

HMMM,

Reply With Quote
  #6  
Old April 12th, 2001, 09:13 AM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
what about this?

html
Code:
<body onUnload="/cgi-bin/userLeaving.pl">


perl
Code:
#!/usr/bin/perl

use CGI;

my $userid = getuserid();
logout($userid);
print header(-status=>'204 No Response');


something like that MIGHT work.

emphasize might. the only other option would be to breifly open a tiny new window that calls the script and have the ouput from the script do a window.close();

the small new window can even let the user know you are logging them out of the system or something like that.

hey, even right when the new window opens you could have a:

windor.opener.focus();

which should move the focus back to the main window while the small logout window does it's stuff in the background?

lemme know how it works out.

Reply With Quote
  #7  
Old April 12th, 2001, 12:00 PM
bigbirdie bigbirdie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Toronto
Posts: 0 bigbirdie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: unobserved's method for user detection / loggin


Yah, thanx again for the ideas, A MAJOR thing i overlooked is that ie. WHen a user is in the welcome html page and then they "unload" to a new page .ie mainscreen.html , then the problem is that they got logged. The nature of this is, that the user can leave anytime, you dont know if they are leaving to another web site or just staying at your site and moving to another page/script/location. So when making the call to perl, you must log that each time. I guess what the thing to do , is to keep updating that record , even though they are not logged off, until they actually are logged off. That means at the beginning of each perl script called from an html based page (perl calling perl - really) you must put the call to update mysql . [ the first time they got logged is when the user logs on to your system- and you INSERT a record into mysql's log table]. When the user jumps to another link/url , they will be logged anways - right up until the actual time they leave the site.

Again, unobserved, the problem with windows in the back , etc, is that the user may only be moving to let say , the browse.html page. Sure, he has moved to another url, but he has not logged out. Unless he manually decides to logout, all is fine and dandy. Many times a user will not log out manually , and just shut down the browser (so the last log will be the last time that user jumped to that last web page) or move off into the sunset.

SUCH is the nature of logging out, hey im sure banks and ie brokerages must have really had some headaches with this one too !

More advice welcome, especially in regard to the entire nature or logic of this problem - ie having a user log in, log his ip address, make sure we know when he has been logged out.

thanx,

bb

Reply With Quote
  #8  
Old April 13th, 2001, 04:14 PM
vpopper's Avatar
vpopper vpopper is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Southern California
Posts: 73 vpopper User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 24 sec
Reputation Power: 9
I'm not sure what your objective is, but if it is that you want aggregate stats for site visitors, you could implement it this way:

Create a "click-through" script that serves requests. When called, it determines if a session id cookie exists. If not, it creates one and stores the start time, the IP, the requested page, etc. If yes, it logs the requested page and a timestamp. It then uses $ENV{REQUEST_URI} or some such mechanism to redirect them to the requested page.

You could then determine:

1). The length of time the user spent on your site (the last request time - the start time). You could average this for all users.

2). The number of pages visited per user (and averages).

3). The pages visited.

etc., etc.

I imagine a table structure like this:

CREATE TABLE sessions (
id int(11) not null primary key,
session_id varchar(128) not null,
ip varchar(15) default '0.0.0.0',
request_time int(11) not null default '0',
page_requested varchar(255),
index (session_id, request_time),
);

Reply With Quote
  #9  
Old April 15th, 2001, 06:22 PM
Adrian2 Adrian2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London, England
Posts: 251 Adrian2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I posted a solution to this problem in PHP on the DevShed PHP board. Perl programmers should have no trouble following it:

http://forums.devshed.com/showthrea...13462&forumid=5

The idea is simply to decide on an arbitrary time limit from the time a user requests a page to when you can consider them gone. Log all page requests with a timestamp and IP address, and then just count all the distinct IP addresses in the log for the last (5) minutes.
__________________
Please don't visit my lame personal website, www.webhamster.co.uk. Half the time it doesn't even work!

Reply With Quote
  #10  
Old April 17th, 2001, 12:58 PM
d0g1e d0g1e is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: The Netherlands
Posts: 8 d0g1e User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to d0g1e
using frames

I'm doing the same kind of thing by using frames. I set a frame to reload every 30 seconds. When the frame reloads, the users_loggedin table is updated and new messages are sent back into this frame. I think you could do the same with an invisible frame.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Determining current users (on your server)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway