Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2163
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: User login status? |
| Date | 2011-06-14 18:57 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <it8p1r$iff$1@dont-email.me> (permalink) |
| References | <545443a6-2c1b-4fa9-902a-967357680506@e7g2000vbw.googlegroups.com> |
On 6/14/2011 4:22 PM, Co wrote:
> Hi All,
>
> I have this code that will change one field of the users record when
> he logs in:
>
> mysql_query("UPDATE myMembers SET last_log_date=now(), logged='1'
> WHERE id='$id' LIMIT 1");
>
> This way we can display all the users who are logged in on the main
> page.
> When the user logs of the record will be changed again:
>
> mysql_query("UPDATE myMembers SET logged='0' WHERE id='$id' LIMIT 1");
>
> However what if the user just forgets to log off, then he is gone but
> his status is still logged=1.
> Is there a way to make sure the user status is changed even when he
> forgets to log off?
>
> Marco
The web is stateless - there is no such concept as "logged in" or not.
And there is no way to know if the user is still reading your page, has
gone to coffee (or lunch), closed the browser or even shut off the
computer. So there is no way to determine how many people are logged in
or not - and sites which claim to do that are pretty much guessing.
The best you can do is create your own custom session handler which
stores the data in a database instead of the file system. Then you can
assume as long as the session is active, the user is logged in. When
the session expires, the user is logged out. Still not real accurate,
but the best you can do.
Just a warning - custom session handlers can be complex and pretty much
beyond what you can do in a newsgroup.
Otherwise, Luuk's response is as good as any. And it will be about as
accurate as anything. You need a cron job to handle the deletion of rows.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
User login status? Co <vonclausowitz@gmail.com> - 2011-06-14 13:22 -0700
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-14 22:57 +0200
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-14 23:00 +0200
Re: User login status? Co <vonclausowitz@gmail.com> - 2011-06-14 14:09 -0700
Re: User login status? Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-14 18:57 -0400
Re: User login status? Co <vonclausowitz@gmail.com> - 2011-06-14 22:02 -0700
Re: User login status? Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-15 06:02 -0400
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-15 20:33 +0200
Re: User login status? Co <vonclausowitz@gmail.com> - 2011-06-17 04:25 -0700
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-17 20:53 +0200
Re: User login status? Bill B <me@privacy.net> - 2011-06-17 15:13 -0400
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-17 22:06 +0200
Re: User login status? Bill B <me@privacy.net> - 2011-06-17 16:39 -0400
Re: User login status? Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 16:47 -0400
Re: User login status? Bill B <me@privacy.net> - 2011-06-17 17:07 -0400
Re: User login status? Tim Streater <timstreater@waitrose.com> - 2011-06-17 22:47 +0100
Re: User login status? Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 20:25 -0400
Re: User login status? Bill B <me@privacy.net> - 2011-06-18 00:15 -0400
Re: User login status? Luuk <Luuk@invalid.lan> - 2011-06-18 13:37 +0200
Re: User login status? Bill B <me@privacy.net> - 2011-06-18 11:46 -0400
csiph-web