Welcome Guest, Not a member yet? Register   Sign In
Strange error in custom library

Hello, I have modified the OnlineUsers library, and changed the file variable to one in the app/data/ directory. I have that section like this:

class Online_users{
    var $file    = APPATH.'data/online_users.tmp';
    var $data;

It says that there is an error in

Parse error: syntax error, unexpected '.', expecting ',' or ';' in application/libraries/Online_users.php on line 15

How can I solve that?

It's complaining about the concatenation dot, you can't put an expression in a class property declaration.

I have changed that into this:
var $file            = 'data/online_users.tmp';
    var $data;
    var $ip;

    function Online_users()
        $this->file        = APPATH.$this->file;

But it tells me this:
Use of undefined constant APPATH - assumed 'APPATH'

How can I use that constant into my library?

[eluser]Jeroen Brussich[/eluser]
don't you mean APPPATH ?

Yes, that was the problem, but I get another error.

Is it possible to know the online users with the session class? doing this?

function online()
        $query                = $this->db->get('sessions');

        return $query->num_rows();

I mean, does the session class delete sessions from the database after $config['sess_time_to_update'] has gone? or it deletes them after $config['sess_expiration']?

It would be easier for me that way. I only want to know how many people has the last activity later than time()-$config['sess_time_to_update'].

Theme © iAndrew 2016 - Forum software by © MyBB