CodeIgniter Forums
How to display if a user is online? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to display if a user is online? (/showthread.php?tid=20532)



How to display if a user is online? - El Forum - 07-13-2009

[eluser]Tyler Diaz[/eluser]
I'm currently experimenting with Code igniter (and PHP) and I am trying to build a simple forum system.

I was wondering how do developers do to show if a user is online or offline on topics and profile. I am using http://dialect.ca/code/ci-simple-login-secure/ - Simple login secure to do the basic login job for me along with using the Code igniter custom session database.

So any leads, tips, advice, snippets, help on how this technique is achieved?


How to display if a user is online? - El Forum - 07-13-2009

[eluser]Michael Wales[/eluser]
Update a field in the table with the timestamp of the last action, if timestamp is within X minutes of now() that user is online.


How to display if a user is online? - El Forum - 07-13-2009

[eluser]Tyler Diaz[/eluser]
Awesome, thank you so much MIchael. Such a basic concept.

Would you recomend a page refresh and action? Or would that put far too much server strain on the database?


How to display if a user is online? - El Forum - 07-13-2009

[eluser]Michael Wales[/eluser]
Not sure I understand what your question is... essentially, on every single page if a user is logged in you will do:

Code:
'UPDATE user SET last_action = '2009-07-13 16:50:00' WHERE id = '1'



How to display if a user is online? - El Forum - 07-13-2009

[eluser]Tyler Diaz[/eluser]
The example you provided answers the question anyway.

I really appreciate the friendly and rapid assistance overall - Thank you.