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 #174507 is a reply to message #174503] Wed, 15 June 2011 10:02 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 6/15/2011 1:02 AM, Co wrote:
> On 15 jun, 00:57, Jerry Stuckle<jstuck...@attglobal.net> 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.
>>
>
> I have been looking at these cron jobs.
> I think I have to create these on the server but I haven't been able
> to find them there.
>
> Marco

That is true - cron jobs (on Linux - Scheduled Tasks on Windows) are
triggered by the OS. Your hosting company may or may not support them.

For more information you need to learn about Linux (or Windows)
administration. Check the OS-related newsgroups for book recommendations.

--
==================
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: Fri Sep 20 11:37:00 GMT 2024

Total time taken to generate the page: 0.03951 seconds