stuart7398 Posted April 9, 2008 Share Posted April 9, 2008 Hi. I wondering how i show if a user is 'online' or 'offline' do i place something in the session? if so , Code / Example / Tutorial would be apprectied. Thanks, Stuart. <code> <?php //Start session session_start(); //Check whether the session variable //SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) { header("location: access-denied.php"); exit(); } ?> </code> Quote Link to comment Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 Well. I don't think you could ever make such a function so that it is 100% accurate. You would most likely base it off the user's activity in the last 5 or 10 minutes. I think you would need to keep a timestamp along with the user/session id in a database, then load the rows that have a timestamp that is newer than 5 minutes or whatever you decide on. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 9, 2008 Share Posted April 9, 2008 If you're monitering registered and logged in users, a usual way would be to add a 'last active' field to your users table, to store a timestamp of the last time they browsed a page - you'll need to have a php file that does this updating, and include it in your other files. Your online list can then be generated by selecting those users who's last active timestamp is less than 5 (or whatever you want) minutes ago. To track guests online, you'll need to store session IDs with a similar method. Quote Link to comment Share on other sites More sharing options...
stuart7398 Posted April 9, 2008 Author Share Posted April 9, 2008 thanks, i'll have a go at that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.