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

(This post was last modified: 01-24-2016, 05:27 PM by moshair.)

Hello,

I am trying to use the Online Users library at:

https://github.com/bcit-ci/CodeIgniter/w...line-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,

Attached Files
.zip   Onlineusers_ci_3b.zip (Size: 5.22 KB / Downloads: 296)
Reply
#2

Because in CI 3 it's set_userdata()
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 01-23-2016, 07:28 AM by moshair.)

(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,
Reply
#4

(This post was last modified: 01-24-2016, 05:26 PM by moshair.)

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 !!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB