FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » User login status?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: User login status? [message #174565 is a reply to message #174560] Sat, 18 June 2011 00:25 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 6/17/2011 5:07 PM, Bill B wrote:
> On 6/17/2011 4:47 PM, Jerry Stuckle wrote:
>> On 6/17/2011 4:39 PM, Bill B wrote:
>>> On 6/17/2011 4:06 PM, Luuk wrote:
>>>> On 17-06-2011 21:13, Bill B wrote:
>>>> > On 6/17/2011 2:53 PM, Luuk wrote:
>>>> >> On 17-06-2011 13:25, Co wrote:
>>>> >>> On 15 jun, 20:33, Luuk<L...@invalid.lan> wrote:
>>>> >>>> On 15-06-2011 00:57, Jerry Stuckle wrote:
>>>> >>>>> 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.
>>>> >>>>
>>>> >>>> You could also check if users are still logged on, just before
>>>> >>>> gathering
>>>> >>>> the list of logged on users...
>>>> >>>> (and when someone logs in)
>>>> >>>>
>>>> >>>> This way your database will not give the correct 'state' to you,
>>>> >>>> but to
>>>> >>>> the web-users it will, because you put all the changes in there
>>>> >>>> before
>>>> >>>> you show anything to the web-users...
>>>> >>>>
>>>> >>>> --
>>>> >>>> Luuk
>>>> >>>
>>>> >>> Luuk,
>>>> >>>
>>>> >>> I like the idea but I don't know exactly how to check if users are
>>>> >>> still logged in?
>>>> >>>
>>>> >>> Marco
>>>> >>
>>>> >> i meant to logg the user off when they have not clicked for a defined
>>>> >> number of minutes (after 10, or 15 minutes, or so....)
>>>> >
>>>> >
>>>> > Any thoughts on how this would work with an<object> that points to a
>>>> > remote swf? The person might be running the swf for some time without
>>>> > causing any activity on the page that contains the<object>.
>>>> >
>>>> > Bill B
>>>> >
>>>> >
>>>>
>>>> swf has nothing to do with PHP.... ;)
>>>>
>>>> I'm not into swf-stuff.....
>>>
>>> The page in question looks like this:
>>> <html>
>>> </html?
>>> <body>
>>> <?php
>>> get $gamepath $game from $_SESSION variables
>>> ?>
>>> <object width type
>>> data=http:domain/$gamepath/$game/game.swf
>>> param name = some stuff
>>> </object>
>>> </body>
>>> </html>
>>>
>>> So, the question, as I understand it, is how to monitor this page for
>>> the inactivity you referred to earlier, when the user could be playing
>>> the swf based game and not move off the page for a while.
>>>
>>> If, for example:
>>>
>>> <?php
>>> while $seconds_since_last click <= $inactivity_limit;
>>> do nothing
>>> endwhile;
>>> logoff_user();
>>> ?>
>>>
>>> would not the focus on the <object> cause the inactivity limit to be
>>> reached [potentially] before the person is finished with the game?
>>>
>>> Unless I'm way off, seems like a PHP question to me.
>>>
>>> Bill B
>>
>> As Luuk indicated, swf has nothing to do with PHP. PHP knows nothing
>> about it and doesn't interact with it. Whether the user is watching a
>> swf, gone to lunch or even just shut off his computer and went home is
>> immaterial to php.
>>
>> The answer is, you can't tell what the user is doing from php. All you
>> can do is tell when the user makes a request to the server.
>
> Jerry, I took Luuk's original suggestion (from above, "i meant to logg
> the user off when they have not clicked for a defined number of minutes
> (after 10, or 15 minutes, or so....)) to mean that some PHP routine
> would check how long it has been since activity, then log the user out.
> If I have missed the mark on that one, I agree with you, the
> conversation is over.
>
> If not, then is this not a question of focus? If <object> has included
> the swf, where is the focus? On the page (containing the PHP code) or on
> the swf? If it is on the swf, then conversation over. But if there is
> still focus on the page with the PHP code, would it not be possible to
> have PHP code that does what Luuk referred to?
>
> Bill B
>
>
> Bill B

As I said. PHP knows nothing about the swf file. It may be on a page
with PHP code, but the PHP code is executed on the server and the
resultant output is sent to the browser. The swf file is processed on
the browser, after the PHP script has ended.

PHP does not execute in the browser, so there is no way for PHP to
determine what is going on at the browser level.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: radio button change after going to next page
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 11:48:40 GMT 2024

Total time taken to generate the page: 0.05176 seconds