Welcome Guest, Not a member yet? Register   Sign In
Users Online Count
#1

[eluser]riwakawd[/eluser]
I would like to know. What is the best way to count the users that are online. And when I refresh page if any have logged out will recalculate the total.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard_user_online extends MX_Controller {

public function __construct() {
  parent::__construct();
  $this->load->model('admin/dashboard/dashboard_user_online_model');

  if ($this->session->userdata('isLogged')) {
   return true;
  } else {
   redirect('admin');
  }
}

public function index() {
  $data['total_user_online'] = $this->dashboard_user_online_model->getTotalUserOnline();

  return $this->load->view('dashboard/dashboard_user_online', $data);

}

}

Model
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard_user_online_model extends CI_Model {

public function getTotalUserOnline() {



}

}
#2

[eluser]CroNiX[/eluser]
There's a timestamp for last_activity in the sessions table. Just grab all that were active in the last 5 minutes or whatever you consider still "online".
#3

[eluser]riwakawd[/eluser]
[quote author="CroNiX" date="1412352188"]There's a timestamp for last_activity in the sessions table. Just grab all that were active in the last 5 minutes or whatever you consider still "online".[/quote]

I got it all sorted out now




Theme © iAndrew 2016 - Forum software by © MyBB