RE: [PHP-DB] Users on line

2003-01-06 Thread Bernain, Fernando G.
OK, guys, thanks!! I'll try it and then I'll tell you!!!

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]




-Original Message-
From: Peter Lovatt [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 7:10 PM
To: Bernain, Fernando G.; 'Peter Beckman'; Hutchins, Richard
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Users on line


Hi

My bank uses two processes. If a user is inactive for more than about 5
minutes it forces you to log in again. This is done server side and just
does not allow you to do anything if your last activity was more than 5
minutes ago. It probably also marks the session as logged out.

It also uses JavaScript  to log you out when you close the
window. Not sure if this works when you just close the browser.

I do have a suggestion, which may or may not meet your needs.

When the user logs in, open a popup window  and set focus to the main window
  so the popup becomes a popunder. Using a header
or meta tag refresh the popunder once a minute and log the session as
already discussed, but with a timeout of 2 minutes, so it will be up to
date. This will tell you that the user has a browser open.

This might be enough for your needs

If not you could use  to post a form to the popup window
when the main window closes. This logs out when the user closes the main
window. The only exception will be if the user navigates away from the site.
If you need to, you could prevent this by displaying site content in another
popup window with no navbar and no external links.

http is stateless, so you cannot do a true session like Messenger but the
above is reasonably close :)

HTH

Peter

---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---

-Original Message-
From: Bernain, Fernando G. [mailto:[EMAIL PROTECTED]]
Sent: 03 January 2003 20:31
To: 'Peter Beckman'; Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I'm thinking in something similar to ICQ or MSN. This is an app for a few
number of users (less than 50) but they need to know who are online when
they are working in the app too!!! Maybe I can use the table online and
insert then name of the user when he login the app... but I still have the
problem of the logout...

I was looking for something (like a function?) in apache or php who tells me
the "open sessions" at a moment...

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]




-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 4:49 PM
To: Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I agree; it'd be nice if there was some sort of code that'd be executed
when someone closed their browser.  There is the javascript "on_exit()" or
something where the user, when they leave a domain, is executed.  However,
this only works if they click off the site, not if they close their
browser.  Plus if they go to another site and come back within 5/10/15
minutes, are they still considered "logged in?"

It's fairly impossible to keep track of when users are or are not using the
site that is not really complex.  What if they are reading an article, run
to the restroom, finish reading the article and then click on another page?
I figure they are "idle" after 15 minutes.  If they continue to surf the
site in an hour or two, their session will be updated (if your sessions
last long enough, or if not they'll probably be automatically re-logged in
which case they'd be updated/re-inserted in the online table), and will
once again be counted as a person online.

One example is forcing people to be logged out after 10 minutes of
inactivity.  Bank of America does this, most likely using javascript.
However, if yahoo! did this when I was reading my mail and I stepped away,
I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
me") so forcing people to log out just to be able to count who is online
seems silly.

If you just want to keep track of how many people are logged in, I'd just
say that logged in is defined as having an active logged in session that
was active in the last 5/10/15 minutes.  I'm almost positive that method is
how most web sites determine time online.

Peter

On Fri, 3 Jan 2003, Hutchins, Richard wrote:

> How would the online table be maintained if a user simply closes out the
> browser without actually logging out properly? I'm not at all experienced
> wit

Re: [PHP-DB] Users on line

2003-01-03 Thread Peter Beckman
Yes, IF the user has cookies turned on.

The cookie is stored on the users computer, regardless of if the IP
changes.  I actually use sessions which have a php.ini set expiration date
of 6 months.  I manually clean the sessions out every night, but the cookie
is set to expire after 6 months.  The reason?  To better track if a user is
giving out his/her username/password.  If a user logs into the site several
times a day with different session IDs, I can be relatively assured that
those logins are not from the same user, especially if logins occur from
completely different IP blocks with different session IDs.

So yes, Session IDs remain constant if users are using/accepting cookies,
regardless of their IP.

Peter

On Fri, 3 Jan 2003, Gerard Samuel wrote:

> I had asked on -questions about something similar to this.
> My concern is how would a setup like this react to a dial up user that
> hops ip addresses (like AOL).  Would the session id remain constant,
> over the ip hops??
> Thanks
>
> Peter Beckman wrote:
>
> >Create a new table named online:
> >
> >id
> >time (int unix timestamp)
> >uid (int probably, user ID of user in question, relating to a user info table?)
> >sessid (char 32 I think)
> >
> >When the user logs in, I assume you set the session.  Insert a row with the
> >current time (unix_timestamp(now()), User ID and the output of session_id()
> >in PHP.  This way you can run a query on that table at any time in one of
> >two ways.
> >
> > 1. select count(id) from online where time>=(unix_timestamp(now())-900)
> >
> >This will give you the number of people who at least logged in in the
> >last 15 minutes.  This isn't very accurate though... so
> >
> > 2. If not already, put sessions in your SQL table.  This way you can run a
> >query like (and John Holmes, please feel free to clean up my joins, i
> >suck at them):
> >
> >select count(*) from online,sessions where
> >online.sessid=sessions.sessid and
> >sessions.date>=(unix_timestamp(now())-900)
> >
> >This will give you the number of users who have done anything on the
> >site in the last 15 minutes.  Change the 900 to 600 or 300 for 10 or 5
> >minutes respectively.
> >
> >Every week or so you'll want to "delete from online where time>=[some
> >number here, unix_timestamp(now()) minus how long you want to leave those
> >entries there]".
> >
> >Depending on how often you want to do this and how busy your site is and
> >how focused on performance you are, I'd advise running it once per minute
> >and every time someone logs in, rather than once per page view, and put the
> >values generated into a text file and read it in with readfile().
> >
> >Peter
> >
> >On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:
> >
> >
> >
> >>I'm working in an app that requires to know who are "on line". When the user
> >>login the app, I use session in order to storage de name and login.  Its
> >>posible to do this???
> >>
> >>Thanks!
> >>
> >>Fernando Bernain
> >>Senior A
> >>Business Process Outsourcing
> >>
> >>KPMG Argentina
> >>Tel: 54 11 4316 5754
> >>Fax: 54 11 4316 5734
> >>[EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >>
> >>Email Disclaimer
> >>
> >>The information in this email is confidential and may be
> >>legally privileged.
> >>It is intended solely for the addressee.
> >>Access to this email by anyone else is unauthorised.
> >>If you are not the intended recipient, any disclosure,
> >>copying, distribution
> >>or any action taken or omitted to be taken in reliance
> >>on it, is prohibited and may be unlawful.
> >>When addressed to our clients any opinions or advice
> >>contained in this email are subject to the terms and
> >>conditions expressed in the governing KPMG client engagement
> >>letter.
> >>
> >>
> >>--
> >>PHP Database Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> >
> >---
> >Peter Beckman  Internet Guy
> >[EMAIL PROTECTED] http://www.purplecow.com/
> >---
> >
> >
> >
>
> --
> Gerard Samuel
> http://www.trini0.org:81/
> http://dev.trini0.org:81/
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Users on line

2003-01-03 Thread Gerard Samuel
I had asked on -questions about something similar to this.
My concern is how would a setup like this react to a dial up user that
hops ip addresses (like AOL).  Would the session id remain constant, 
over the ip hops??
Thanks

Peter Beckman wrote:

Create a new table named online:

id
time (int unix timestamp)
uid (int probably, user ID of user in question, relating to a user info table?)
sessid (char 32 I think)

When the user logs in, I assume you set the session.  Insert a row with the
current time (unix_timestamp(now()), User ID and the output of session_id()
in PHP.  This way you can run a query on that table at any time in one of
two ways.

1. select count(id) from online where time>=(unix_timestamp(now())-900)

   This will give you the number of people who at least logged in in the
   last 15 minutes.  This isn't very accurate though... so

2. If not already, put sessions in your SQL table.  This way you can run a
   query like (and John Holmes, please feel free to clean up my joins, i
   suck at them):

   select count(*) from online,sessions where
   online.sessid=sessions.sessid and
   sessions.date>=(unix_timestamp(now())-900)

   This will give you the number of users who have done anything on the
   site in the last 15 minutes.  Change the 900 to 600 or 300 for 10 or 5
   minutes respectively.

Every week or so you'll want to "delete from online where time>=[some
number here, unix_timestamp(now()) minus how long you want to leave those
entries there]".

Depending on how often you want to do this and how busy your site is and
how focused on performance you are, I'd advise running it once per minute
and every time someone logs in, rather than once per page view, and put the
values generated into a text file and read it in with readfile().

Peter

On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:

 

I'm working in an app that requires to know who are "on line". When the user
login the app, I use session in order to storage de name and login.  Its
posible to do this???

Thanks!

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]





Email Disclaimer

The information in this email is confidential and may be
legally privileged.
It is intended solely for the addressee.
Access to this email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure,
copying, distribution
or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.
When addressed to our clients any opinions or advice
contained in this email are subject to the terms and
conditions expressed in the governing KPMG client engagement
letter.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

   


---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

 


--
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Users on line

2003-01-03 Thread Peter Beckman
Again, a person who is idle for more than x number of minutes (1-15 in my
mind) is no longer online.  Do they need to be logged out?  On every page
you could have a javascript timer which logs the user out if they are idle
for more than x minutes in addition to the onunload="logoutfunction()" in
the body tag in Javascript to log them out.

// This assumes that sessions.gc (garbage collection) is on and that your
// session timeout is set to whatever you want sessions to be limited to
function number_of_open_sessions() {
  $r = mysql_query("select count(*) as c from php.phpsessions");
  $x = mysql_fetch_array($r);
  return $x['c'];
}

// or if a file system
function number_of_open_sessions() {
  $x = ini_get("session.save_path");
  // look for files in this dir that start with sess_
  // count them
  // return the number of files that match.
}

Peter

On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:

> I'm thinking in something similar to ICQ or MSN. This is an app for a few
> number of users (less than 50) but they need to know who are online when
> they are working in the app too!!! Maybe I can use the table online and
> insert then name of the user when he login the app... but I still have the
> problem of the logout...
>
> I was looking for something (like a function?) in apache or php who tells me
> the "open sessions" at a moment...
>
> Fernando Bernain
> Senior A
> Business Process Outsourcing
>
> KPMG Argentina
> Tel: 54 11 4316 5754
> Fax: 54 11 4316 5734
> [EMAIL PROTECTED]
>
>
>
>
> -Original Message-
> From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 03, 2003 4:49 PM
> To: Hutchins, Richard
> Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
> Subject: RE: [PHP-DB] Users on line
>
>
> I agree; it'd be nice if there was some sort of code that'd be executed
> when someone closed their browser.  There is the javascript "on_exit()" or
> something where the user, when they leave a domain, is executed.  However,
> this only works if they click off the site, not if they close their
> browser.  Plus if they go to another site and come back within 5/10/15
> minutes, are they still considered "logged in?"
>
> It's fairly impossible to keep track of when users are or are not using the
> site that is not really complex.  What if they are reading an article, run
> to the restroom, finish reading the article and then click on another page?
> I figure they are "idle" after 15 minutes.  If they continue to surf the
> site in an hour or two, their session will be updated (if your sessions
> last long enough, or if not they'll probably be automatically re-logged in
> which case they'd be updated/re-inserted in the online table), and will
> once again be counted as a person online.
>
> One example is forcing people to be logged out after 10 minutes of
> inactivity.  Bank of America does this, most likely using javascript.
> However, if yahoo! did this when I was reading my mail and I stepped away,
> I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
> me") so forcing people to log out just to be able to count who is online
> seems silly.
>
> If you just want to keep track of how many people are logged in, I'd just
> say that logged in is defined as having an active logged in session that
> was active in the last 5/10/15 minutes.  I'm almost positive that method is
> how most web sites determine time online.
>
> Peter
>
> On Fri, 3 Jan 2003, Hutchins, Richard wrote:
>
> > How would the online table be maintained if a user simply closes out the
> > browser without actually logging out properly? I'm not at all experienced
> > with sessions, but closing the browser should terminate the session,
> > correct? Bernain may want to delete from his online table every hour or so
> > to catch those people who have not properly logged out (assuming the
> "delete
> > from online..." query is only fired when they click on a "log out"
> button).
> >
> > I'm not slagging Peter's recommendation. I was thinking this solution
> > through as well, but was a bit stuck when it came to users just closing
> > their browsers without logging out.
> >
> > > -Original Message-
> > > From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, January 03, 2003 2:32 PM
> > > To: Bernain, Fernando G.
> > > Cc: '[EMAIL PROTECTED]'
> > > Subject: Re: [PHP-DB] Users on line
> > >
> > >
> > > Create a new table named online:
> > >
> > > id
> > &

RE: [PHP-DB] Users on line

2003-01-03 Thread Peter Lovatt
Hi

Better still :)

I know more now than I did ten minutes ago - Its not nitpicking its useful

Peter

---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---

-Original Message-
From: Matthew Moldvan [mailto:[EMAIL PROTECTED]]
Sent: 03 January 2003 22:24
To: 'Peter Lovatt'; Bernain, Fernando G.; 'Peter Beckman'; Hutchins,
Richard
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Users on line


Don't mean to nitpick, but from what I read onUnload works both when
navigating away and when closing ...

:)

Regards,
Matthew Moldvan

---
 System Administrator
 Trilogy International, Inc
 http://www.trilogyintl.com/ecommerce/
---

-Original Message-
From: Peter Lovatt [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 5:10 PM
To: Bernain, Fernando G.; 'Peter Beckman'; Hutchins, Richard
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Users on line


-- snip --

The only exception will be if the user navigates away from the site.
If you need to, you could prevent this by displaying site content in another
popup window with no navbar and no external links.

http is stateless, so you cannot do a true session like Messenger but the
above is reasonably close :)

HTH

Peter

---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Users on line

2003-01-03 Thread Matthew Moldvan
Don't mean to nitpick, but from what I read onUnload works both when
navigating away and when closing ...

:)

Regards,
Matthew Moldvan

---
 System Administrator
 Trilogy International, Inc
 http://www.trilogyintl.com/ecommerce/
---

-Original Message-
From: Peter Lovatt [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 5:10 PM
To: Bernain, Fernando G.; 'Peter Beckman'; Hutchins, Richard
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Users on line


-- snip --

The only exception will be if the user navigates away from the site.
If you need to, you could prevent this by displaying site content in another
popup window with no navbar and no external links.

http is stateless, so you cannot do a true session like Messenger but the
above is reasonably close :)

HTH

Peter

---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Users on line

2003-01-03 Thread Peter Lovatt
Hi

My bank uses two processes. If a user is inactive for more than about 5
minutes it forces you to log in again. This is done server side and just
does not allow you to do anything if your last activity was more than 5
minutes ago. It probably also marks the session as logged out.

It also uses JavaScript  to log you out when you close the
window. Not sure if this works when you just close the browser.

I do have a suggestion, which may or may not meet your needs.

When the user logs in, open a popup window  and set focus to the main window
  so the popup becomes a popunder. Using a header
or meta tag refresh the popunder once a minute and log the session as
already discussed, but with a timeout of 2 minutes, so it will be up to
date. This will tell you that the user has a browser open.

This might be enough for your needs

If not you could use  to post a form to the popup window
when the main window closes. This logs out when the user closes the main
window. The only exception will be if the user navigates away from the site.
If you need to, you could prevent this by displaying site content in another
popup window with no navbar and no external links.

http is stateless, so you cannot do a true session like Messenger but the
above is reasonably close :)

HTH

Peter

---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---

-Original Message-
From: Bernain, Fernando G. [mailto:[EMAIL PROTECTED]]
Sent: 03 January 2003 20:31
To: 'Peter Beckman'; Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I'm thinking in something similar to ICQ or MSN. This is an app for a few
number of users (less than 50) but they need to know who are online when
they are working in the app too!!! Maybe I can use the table online and
insert then name of the user when he login the app... but I still have the
problem of the logout...

I was looking for something (like a function?) in apache or php who tells me
the "open sessions" at a moment...

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]




-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 4:49 PM
To: Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I agree; it'd be nice if there was some sort of code that'd be executed
when someone closed their browser.  There is the javascript "on_exit()" or
something where the user, when they leave a domain, is executed.  However,
this only works if they click off the site, not if they close their
browser.  Plus if they go to another site and come back within 5/10/15
minutes, are they still considered "logged in?"

It's fairly impossible to keep track of when users are or are not using the
site that is not really complex.  What if they are reading an article, run
to the restroom, finish reading the article and then click on another page?
I figure they are "idle" after 15 minutes.  If they continue to surf the
site in an hour or two, their session will be updated (if your sessions
last long enough, or if not they'll probably be automatically re-logged in
which case they'd be updated/re-inserted in the online table), and will
once again be counted as a person online.

One example is forcing people to be logged out after 10 minutes of
inactivity.  Bank of America does this, most likely using javascript.
However, if yahoo! did this when I was reading my mail and I stepped away,
I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
me") so forcing people to log out just to be able to count who is online
seems silly.

If you just want to keep track of how many people are logged in, I'd just
say that logged in is defined as having an active logged in session that
was active in the last 5/10/15 minutes.  I'm almost positive that method is
how most web sites determine time online.

Peter

On Fri, 3 Jan 2003, Hutchins, Richard wrote:

> How would the online table be maintained if a user simply closes out the
> browser without actually logging out properly? I'm not at all experienced
> with sessions, but closing the browser should terminate the session,
> correct? Bernain may want to delete from his online table every hour or so
> to catch those people who have not properly logged out (assuming the
"delete
> from online..." query is only fired when they click on a "log out"
button).
>
> I'm not slagging Peter's recommendation. I was thinking this solution
> through as well, but wa

RE: [PHP-DB] Users on line

2003-01-03 Thread Bernain, Fernando G.
I'm thinking in something similar to ICQ or MSN. This is an app for a few
number of users (less than 50) but they need to know who are online when
they are working in the app too!!! Maybe I can use the table online and
insert then name of the user when he login the app... but I still have the
problem of the logout...

I was looking for something (like a function?) in apache or php who tells me
the "open sessions" at a moment...

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]




-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 4:49 PM
To: Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I agree; it'd be nice if there was some sort of code that'd be executed
when someone closed their browser.  There is the javascript "on_exit()" or
something where the user, when they leave a domain, is executed.  However,
this only works if they click off the site, not if they close their
browser.  Plus if they go to another site and come back within 5/10/15
minutes, are they still considered "logged in?"

It's fairly impossible to keep track of when users are or are not using the
site that is not really complex.  What if they are reading an article, run
to the restroom, finish reading the article and then click on another page?
I figure they are "idle" after 15 minutes.  If they continue to surf the
site in an hour or two, their session will be updated (if your sessions
last long enough, or if not they'll probably be automatically re-logged in
which case they'd be updated/re-inserted in the online table), and will
once again be counted as a person online.

One example is forcing people to be logged out after 10 minutes of
inactivity.  Bank of America does this, most likely using javascript.
However, if yahoo! did this when I was reading my mail and I stepped away,
I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
me") so forcing people to log out just to be able to count who is online
seems silly.

If you just want to keep track of how many people are logged in, I'd just
say that logged in is defined as having an active logged in session that
was active in the last 5/10/15 minutes.  I'm almost positive that method is
how most web sites determine time online.

Peter

On Fri, 3 Jan 2003, Hutchins, Richard wrote:

> How would the online table be maintained if a user simply closes out the
> browser without actually logging out properly? I'm not at all experienced
> with sessions, but closing the browser should terminate the session,
> correct? Bernain may want to delete from his online table every hour or so
> to catch those people who have not properly logged out (assuming the
"delete
> from online..." query is only fired when they click on a "log out"
button).
>
> I'm not slagging Peter's recommendation. I was thinking this solution
> through as well, but was a bit stuck when it came to users just closing
> their browsers without logging out.
>
> > -Original Message-----
> > From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, January 03, 2003 2:32 PM
> > To: Bernain, Fernando G.
> > Cc: '[EMAIL PROTECTED]'
> > Subject: Re: [PHP-DB] Users on line
> >
> >
> > Create a new table named online:
> >
> > id
> > time (int unix timestamp)
> > uid (int probably, user ID of user in question, relating to a
> > user info table?)
> > sessid (char 32 I think)
> >
> > When the user logs in, I assume you set the session.  Insert
> > a row with the
> > current time (unix_timestamp(now()), User ID and the output
> > of session_id()
> > in PHP.  This way you can run a query on that table at any
> > time in one of
> > two ways.
> >
> >  1. select count(id) from online where
> > time>=(unix_timestamp(now())-900)
> >
> > This will give you the number of people who at least
> > logged in in the
> > last 15 minutes.  This isn't very accurate though... so
> >
> >  2. If not already, put sessions in your SQL table.  This way
> > you can run a
> > query like (and John Holmes, please feel free to clean up
> > my joins, i
> > suck at them):
> >
> > select count(*) from online,sessions where
> > online.sessid=sessions.sessid and
> > sessions.date>=(unix_timestamp(now())-900)
> >
> > This will give you the number of users who have done
> > anything on the
> > site in the last 15 minutes.  Change the 900 to 600 or
> > 300 for 10 or

RE: [PHP-DB] Users on line

2003-01-03 Thread Matthew Moldvan
I think the easiest way to do this would be to use the JavaScript
"onClose();" to load the PHP logout page ... that works whether they simply
leave the page or whether they close the browser also.

Regards,
Matthew Moldvan

---
 System Administrator
 Trilogy International, Inc
 http://www.trilogyintl.com/ecommerce/
---

-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 2:49 PM
To: Hutchins, Richard
Cc: Bernain, Fernando G.; '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] Users on line


I agree; it'd be nice if there was some sort of code that'd be executed
when someone closed their browser.  There is the javascript "on_exit()" or
something where the user, when they leave a domain, is executed.  However,
this only works if they click off the site, not if they close their
browser.  Plus if they go to another site and come back within 5/10/15
minutes, are they still considered "logged in?"

It's fairly impossible to keep track of when users are or are not using the
site that is not really complex.  What if they are reading an article, run
to the restroom, finish reading the article and then click on another page?
I figure they are "idle" after 15 minutes.  If they continue to surf the
site in an hour or two, their session will be updated (if your sessions
last long enough, or if not they'll probably be automatically re-logged in
which case they'd be updated/re-inserted in the online table), and will
once again be counted as a person online.

One example is forcing people to be logged out after 10 minutes of
inactivity.  Bank of America does this, most likely using javascript.
However, if yahoo! did this when I was reading my mail and I stepped away,
I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
me") so forcing people to log out just to be able to count who is online
seems silly.

If you just want to keep track of how many people are logged in, I'd just
say that logged in is defined as having an active logged in session that
was active in the last 5/10/15 minutes.  I'm almost positive that method is
how most web sites determine time online.

Peter

On Fri, 3 Jan 2003, Hutchins, Richard wrote:

> How would the online table be maintained if a user simply closes out the
> browser without actually logging out properly? I'm not at all experienced
> with sessions, but closing the browser should terminate the session,
> correct? Bernain may want to delete from his online table every hour or so
> to catch those people who have not properly logged out (assuming the
"delete
> from online..." query is only fired when they click on a "log out"
button).
>
> I'm not slagging Peter's recommendation. I was thinking this solution
> through as well, but was a bit stuck when it came to users just closing
> their browsers without logging out.
>
> > -Original Message-----
> > From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, January 03, 2003 2:32 PM
> > To: Bernain, Fernando G.
> > Cc: '[EMAIL PROTECTED]'
> > Subject: Re: [PHP-DB] Users on line
> >
> >
> > Create a new table named online:
> >
> > id
> > time (int unix timestamp)
> > uid (int probably, user ID of user in question, relating to a
> > user info table?)
> > sessid (char 32 I think)
> >
> > When the user logs in, I assume you set the session.  Insert
> > a row with the
> > current time (unix_timestamp(now()), User ID and the output
> > of session_id()
> > in PHP.  This way you can run a query on that table at any
> > time in one of
> > two ways.
> >
> >  1. select count(id) from online where
> > time>=(unix_timestamp(now())-900)
> >
> > This will give you the number of people who at least
> > logged in in the
> > last 15 minutes.  This isn't very accurate though... so
> >
> >  2. If not already, put sessions in your SQL table.  This way
> > you can run a
> > query like (and John Holmes, please feel free to clean up
> > my joins, i
> > suck at them):
> >
> > select count(*) from online,sessions where
> > online.sessid=sessions.sessid and
> > sessions.date>=(unix_timestamp(now())-900)
> >
> > This will give you the number of users who have done
> > anything on the
> > site in the last 15 minutes.  Change the 900 to 600 or
> > 300 for 10 or 5
> > minutes respectively.
> >
> > Every week or so you'll want to "delete from online where time>=[some
> > number here, unix_timesta

RE: [PHP-DB] Users on line

2003-01-03 Thread Peter Beckman
I agree; it'd be nice if there was some sort of code that'd be executed
when someone closed their browser.  There is the javascript "on_exit()" or
something where the user, when they leave a domain, is executed.  However,
this only works if they click off the site, not if they close their
browser.  Plus if they go to another site and come back within 5/10/15
minutes, are they still considered "logged in?"

It's fairly impossible to keep track of when users are or are not using the
site that is not really complex.  What if they are reading an article, run
to the restroom, finish reading the article and then click on another page?
I figure they are "idle" after 15 minutes.  If they continue to surf the
site in an hour or two, their session will be updated (if your sessions
last long enough, or if not they'll probably be automatically re-logged in
which case they'd be updated/re-inserted in the online table), and will
once again be counted as a person online.

One example is forcing people to be logged out after 10 minutes of
inactivity.  Bank of America does this, most likely using javascript.
However, if yahoo! did this when I was reading my mail and I stepped away,
I'd be annoyed.  Most sites allow you to be logged in forever ("Remember
me") so forcing people to log out just to be able to count who is online
seems silly.

If you just want to keep track of how many people are logged in, I'd just
say that logged in is defined as having an active logged in session that
was active in the last 5/10/15 minutes.  I'm almost positive that method is
how most web sites determine time online.

Peter

On Fri, 3 Jan 2003, Hutchins, Richard wrote:

> How would the online table be maintained if a user simply closes out the
> browser without actually logging out properly? I'm not at all experienced
> with sessions, but closing the browser should terminate the session,
> correct? Bernain may want to delete from his online table every hour or so
> to catch those people who have not properly logged out (assuming the "delete
> from online..." query is only fired when they click on a "log out" button).
>
> I'm not slagging Peter's recommendation. I was thinking this solution
> through as well, but was a bit stuck when it came to users just closing
> their browsers without logging out.
>
> > -Original Message-
> > From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, January 03, 2003 2:32 PM
> > To: Bernain, Fernando G.
> > Cc: '[EMAIL PROTECTED]'
> > Subject: Re: [PHP-DB] Users on line
> >
> >
> > Create a new table named online:
> >
> > id
> > time (int unix timestamp)
> > uid (int probably, user ID of user in question, relating to a
> > user info table?)
> > sessid (char 32 I think)
> >
> > When the user logs in, I assume you set the session.  Insert
> > a row with the
> > current time (unix_timestamp(now()), User ID and the output
> > of session_id()
> > in PHP.  This way you can run a query on that table at any
> > time in one of
> > two ways.
> >
> >  1. select count(id) from online where
> > time>=(unix_timestamp(now())-900)
> >
> > This will give you the number of people who at least
> > logged in in the
> > last 15 minutes.  This isn't very accurate though... so
> >
> >  2. If not already, put sessions in your SQL table.  This way
> > you can run a
> > query like (and John Holmes, please feel free to clean up
> > my joins, i
> > suck at them):
> >
> > select count(*) from online,sessions where
> > online.sessid=sessions.sessid and
> > sessions.date>=(unix_timestamp(now())-900)
> >
> > This will give you the number of users who have done
> > anything on the
> > site in the last 15 minutes.  Change the 900 to 600 or
> > 300 for 10 or 5
> > minutes respectively.
> >
> > Every week or so you'll want to "delete from online where time>=[some
> > number here, unix_timestamp(now()) minus how long you want to
> > leave those
> > entries there]".
> >
> > Depending on how often you want to do this and how busy your
> > site is and
> > how focused on performance you are, I'd advise running it
> > once per minute
> > and every time someone logs in, rather than once per page
> > view, and put the
> > values generated into a text file and read it in with readfile().
> >
> > Peter
> >
> > On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:
> >
> > > I'm working in an app that requires to know w

RE: [PHP-DB] Users on line

2003-01-03 Thread Hutchins, Richard
How would the online table be maintained if a user simply closes out the
browser without actually logging out properly? I'm not at all experienced
with sessions, but closing the browser should terminate the session,
correct? Bernain may want to delete from his online table every hour or so
to catch those people who have not properly logged out (assuming the "delete
from online..." query is only fired when they click on a "log out" button).

I'm not slagging Peter's recommendation. I was thinking this solution
through as well, but was a bit stuck when it came to users just closing
their browsers without logging out.

> -Original Message-
> From: Peter Beckman [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 03, 2003 2:32 PM
> To: Bernain, Fernando G.
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: [PHP-DB] Users on line
> 
> 
> Create a new table named online:
> 
> id
> time (int unix timestamp)
> uid (int probably, user ID of user in question, relating to a 
> user info table?)
> sessid (char 32 I think)
> 
> When the user logs in, I assume you set the session.  Insert 
> a row with the
> current time (unix_timestamp(now()), User ID and the output 
> of session_id()
> in PHP.  This way you can run a query on that table at any 
> time in one of
> two ways.
> 
>  1. select count(id) from online where 
> time>=(unix_timestamp(now())-900)
> 
> This will give you the number of people who at least 
> logged in in the
> last 15 minutes.  This isn't very accurate though... so
> 
>  2. If not already, put sessions in your SQL table.  This way 
> you can run a
> query like (and John Holmes, please feel free to clean up 
> my joins, i
> suck at them):
> 
> select count(*) from online,sessions where
> online.sessid=sessions.sessid and
> sessions.date>=(unix_timestamp(now())-900)
> 
> This will give you the number of users who have done 
> anything on the
> site in the last 15 minutes.  Change the 900 to 600 or 
> 300 for 10 or 5
> minutes respectively.
> 
> Every week or so you'll want to "delete from online where time>=[some
> number here, unix_timestamp(now()) minus how long you want to 
> leave those
> entries there]".
> 
> Depending on how often you want to do this and how busy your 
> site is and
> how focused on performance you are, I'd advise running it 
> once per minute
> and every time someone logs in, rather than once per page 
> view, and put the
> values generated into a text file and read it in with readfile().
> 
> Peter
> 
> On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:
> 
> > I'm working in an app that requires to know who are "on 
> line". When the user
> > login the app, I use session in order to storage de name 
> and login.  Its
> > posible to do this???
> >
> > Thanks!
> >
> > Fernando Bernain
> > Senior A
> > Business Process Outsourcing
> >
> > KPMG Argentina
> > Tel: 54 11 4316 5754
> > Fax: 54 11 4316 5734
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> > Email Disclaimer
> >
> > The information in this email is confidential and may be
> > legally privileged.
> > It is intended solely for the addressee.
> > Access to this email by anyone else is unauthorised.
> > If you are not the intended recipient, any disclosure,
> > copying, distribution
> > or any action taken or omitted to be taken in reliance
> > on it, is prohibited and may be unlawful.
> > When addressed to our clients any opinions or advice
> > contained in this email are subject to the terms and
> > conditions expressed in the governing KPMG client engagement
> > letter.
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> -
> Peter Beckman 
>  Internet Guy
> [EMAIL PROTECTED] 
> http://www.purplecow.com/
> --
> -
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Users on line

2003-01-03 Thread Peter Beckman
Create a new table named online:

id
time (int unix timestamp)
uid (int probably, user ID of user in question, relating to a user info table?)
sessid (char 32 I think)

When the user logs in, I assume you set the session.  Insert a row with the
current time (unix_timestamp(now()), User ID and the output of session_id()
in PHP.  This way you can run a query on that table at any time in one of
two ways.

 1. select count(id) from online where time>=(unix_timestamp(now())-900)

This will give you the number of people who at least logged in in the
last 15 minutes.  This isn't very accurate though... so

 2. If not already, put sessions in your SQL table.  This way you can run a
query like (and John Holmes, please feel free to clean up my joins, i
suck at them):

select count(*) from online,sessions where
online.sessid=sessions.sessid and
sessions.date>=(unix_timestamp(now())-900)

This will give you the number of users who have done anything on the
site in the last 15 minutes.  Change the 900 to 600 or 300 for 10 or 5
minutes respectively.

Every week or so you'll want to "delete from online where time>=[some
number here, unix_timestamp(now()) minus how long you want to leave those
entries there]".

Depending on how often you want to do this and how busy your site is and
how focused on performance you are, I'd advise running it once per minute
and every time someone logs in, rather than once per page view, and put the
values generated into a text file and read it in with readfile().

Peter

On Fri, 3 Jan 2003, Bernain, Fernando G. wrote:

> I'm working in an app that requires to know who are "on line". When the user
> login the app, I use session in order to storage de name and login.  Its
> posible to do this???
>
> Thanks!
>
> Fernando Bernain
> Senior A
> Business Process Outsourcing
>
> KPMG Argentina
> Tel: 54 11 4316 5754
> Fax: 54 11 4316 5734
> [EMAIL PROTECTED]
>
>
>
>
>
> Email Disclaimer
>
> The information in this email is confidential and may be
> legally privileged.
> It is intended solely for the addressee.
> Access to this email by anyone else is unauthorised.
> If you are not the intended recipient, any disclosure,
> copying, distribution
> or any action taken or omitted to be taken in reliance
> on it, is prohibited and may be unlawful.
> When addressed to our clients any opinions or advice
> contained in this email are subject to the terms and
> conditions expressed in the governing KPMG client engagement
> letter.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Users on line

2003-01-03 Thread Bernain, Fernando G.
I'm working in an app that requires to know who are "on line". When the user
login the app, I use session in order to storage de name and login.  Its
posible to do this???

Thanks!

Fernando Bernain
Senior A
Business Process Outsourcing

KPMG Argentina
Tel: 54 11 4316 5754
Fax: 54 11 4316 5734
[EMAIL PROTECTED]





Email Disclaimer

The information in this email is confidential and may be
legally privileged.
It is intended solely for the addressee.
Access to this email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure,
copying, distribution
or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.
When addressed to our clients any opinions or advice
contained in this email are subject to the terms and
conditions expressed in the governing KPMG client engagement
letter.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php