Re: Handling competing edits in a wiki engine?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Murray @ PlanetThoughtful wrote:
> 
> Out of curiosity, does anyone know if it's possible to tell whether an
> individual session is still alive from PHP? I don't mean from within
> code being run for a particular user, but in code that, for example,
> might be executed by a cron job, which would examine a table in which
> session ids have been recorded automatically for each visitor, and
> determining which of those sessions are still theoretically alive? I
> suspect this isn't possible, but I've also learned to never
> underestimate the ingenuity of those faced with things that aren't
> possible.
> 

[Ok, I AM an AJAX fan]

The problem with "normal" session management is that session data
(timestamp etc.) gets updated only when and if the user does something:
therefore, if he is reading an article and he doesn't click anywhere for
10 minutes, he still is on your site, but you "lose" him.

An alternative approach is the AJAX [1] one: you set up a JavaScript
'setInterval' and call an "AJAX" function that makes a query to the PHP
script that updates the session (with the current timestamp, user_id,
whatever...)
Ok, I don't know if this makes much sense, but you end up with a script
that gets executed (without user interaction) every 'n' microseconds, so
your session data is always up to date (at maximum, with a delay of 'n'
* 2 microseconds).
The bad side of this is that you have a script that gets executed quite
often for every user visiting your pages: but, if you keep it minimal (a
couple of queries) the overhead isn't that much and you get a
*near-to-real* number of open sessions.

I hope I made some sense: in any case feel free to ask, I just developed
something like this for a web site I'm working on (but we're still in
alpha), so if you want to see it in action, lemme know.

Ciao!
Silvio

[1] http://en.wikipedia.org/wiki/AJAX

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux