Reply to Re: what to do if user forgot to log out?

Your name:

Reply:


Posted by Oli Filth on 10/16/14 11:18

cyberhorse said the following on 12/06/2005 08:51:
> One reason to want to have something run on logout/session time out is
> to keep track of online/offline users (many bulletin boards have to
> deal with this problem).
>
> One solution is to have a function call at the beginning of each page
> that checks if it has been 5 minutes (or whatever time you want) since
> the last action of all users. You keep track of all users yourself
> through database entries or something similar and if some of them
> appear inactive, you clean them up.
>
> This can has a negative impact on performance as you are running a lot
> of code that in most cases will do nothing

It shouldn't have that much of an effect if you push the clean-up into
the database query, i.e. you do something like:

UPDATE users SET online = 0 WHERE (lastOnlineTime + x) < NOW()

Although I haven't tested the speed of this, so I could be wrong! It's
almost certainly faster than doing it in manually in PHP though. (You
could probably optimise this by adding "online = 1 AND" into the WHERE
clause, and indexing the online column... maybe)

> It also has the side-effect that if your site in
> general is not very popular, the clean up may happen hours later, when
> the next visitor comes to see a page. This second disadvantage is
> addressed below.

Is this one really a disadvantage though? You're right, the clear-up
won't happen for hours, but there's no-one using the site in the interim
to find this out!!

The update still occurs exactly when it needs to, i.e. just before a
user uses the site/page.


--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация