CodeIgniter Forums
Online Users library Addin - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Online Users library Addin (/showthread.php?tid=64169)



Online Users library Addin - moshair - 01-22-2016

Hello,

I am trying to use the Online Users library at:

https://github.com/bcit-ci/CodeIgniter/wiki/Library:-Online-Users

In config/autoload.php I set:

Code:
$autoload['libraries'] = array('database','session','onlineusers');

I use Codeigniter v3.0.4

The problem is in set_data() it is not working, I use "Authme Authentication Library"
* @author Gilbert Pellegrom
* @LinK http://dev7studios.com
* @version 1.0

I added the code to the libraries/Authme.php

Code:
$this->CI->onlineusers->set_data(array('username'=>$user->username,'id'=>$user->id), 1);

Onlineusers.php, and Authme.php are attached. Can someone help me?

Also I tried to use set_data in a controller; it is not working! Huh

Regards,


RE: set_data is notworking in Online Users library - InsiteFX - 01-23-2016

Because in CI 3 it's set_userdata()


RE: set_data is notworking in Online Users library - moshair - 01-23-2016

(01-23-2016, 04:39 AM)InsiteFX Wrote: Because in CI 3 it's set_userdata()

Thank you InsiteFX,

set_data is a function in the library class 'Onlineusers'.

The problem in changing online guest to member, it requires 15 min to update him.

I have two solutions:
1. Reducing the time out to a small number like 15 instead of 900 in line:
$timeout = $now - 900;

Is this bad a take more resources?

2. Loading online library only for logged in users; so there will be no guests. But I will not know online guests and bots.

Does any one know another library depends on database not file and store online and today users?

Regards,


RE: set_data is notworking in Online Users library - moshair - 01-24-2016

In Onlineusers.php I changed set_data function to:

Code:
function set_data($username, $id) {
    $aryData = $this->data['useronline'];
      $aryData[$this->ip]['username'] = $username;
      $aryData[$this->ip]['id'] = $id;
    $this->data['useronline'] = $aryData;
    $this->_save();
  }

In Authme.php I changed

Code:
$this->CI->onlineusers->set_data(array('username'=>$user->username,'id'=>$user->id), 1);

to

Code:
$this->CI->onlineusers->set_data($user->username,$user->id);

in login function

and
Code:
$this->CI->onlineusers->set_data('','');
in logout function

now it is working fine. But I still think it is bad idea to use this library because it use file to store online information.

Any ideas !!!