1 (edited by Peter 2007-03-18 21:53)

Topic: Never more than 1 user in 'online' table - what did I mess up now?

I've made lots of changes to use PunBB registration for my entire site. Everything works fine, but in the list 'registered users online' there's never more than one name.

In a clean test install when I log in on a second laptop the second name shows up at 'online'. When I check in MySQL both logged in users are in the 'online' table.

I can't get that to work in my customized site. sad

Which code should I check? What code puts the entries in the 'online' table? Is there code that makes sure names are added to that table and don't replace the name that's already there?

edit:

In login.php I only see the online table mentioned here:

    // Remove this users guest entry from the online list
    $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape(get_remote_address()).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());

    $expire = ($save_pass == '1') ? time() + 31536000 : 0;
    pun_setcookie($user_id, $form_password_hash, $expire);

    redirect(htmlspecialchars($_POST['redirect_url']), $lang_login['Login redirect']);
}


else if ($action == 'out')
{
    if ($pun_user['is_guest'] || !isset($_GET['id']) || $_GET['id'] != $pun_user['id'])
    {
        header('Location: index.php');
        exit;
    }

    // Remove user from "users online" list.
    $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$pun_user['id']) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());

It's all about 'removing' from the online table, not 'adding'! WTF?

edit2:

Could my problem have something to do with this at the top of my index.php page?

define('PUN_QUIET_VISIT', 1);
define('PUN_ALLOW_INDEX', 1);

I thought I needed those lines for files outside regular PunBB, but removing them doesn't seem to have any effect either way...

Re: Never more than 1 user in 'online' table - what did I mess up now?

The online entries are added in the check_cookie function in include/functions.php

3 (edited by Peter 2007-03-18 22:27)

Re: Never more than 1 user in 'online' table - what did I mess up now?

Thanks again Smartys. I had quickly checked those lines. They look the same. I'll have a closer look, but some other customization I've made probably broke it in an unexpected way. Something to do with rearranging folders perhaps. hmm

edit:

I've replaced that fuction with the original code to make sure, but it has no effect. When I watch the online table and log in with different browser, one user just replaces the other.

Re: Never more than 1 user in 'online' table - what did I mess up now?

Well, if their first visit is to a page with define('PUN_QUIET_VISIT', 1) in it, they won't be inserted into the table.

5 (edited by Peter 2007-03-19 03:14)

Re: Never more than 1 user in 'online' table - what did I mess up now?

Smartys wrote:

Well, if their first visit is to a page with define('PUN_QUIET_VISIT', 1) in it, they won't be inserted into the table.

OK, that makes a lot of sense. I'd already taken it out of index.php and login.php. No effect yet, but I'll check if there are more files included with that line.

edit:
Still no change. When I log in on one browser (Firefox) the user shows up in 'online' on the site and in MySQL. But when I open the site on another browser there are 0 registered users online and only an anonymous guest when I check the same MySQL database. WTF?

edit:
Found the cause. In admin_options 'online timeout' (number of seconds a user must be idle before being removed from the online members list) was set to 0.

I should have thought of this sooner. admin_options also caused this problem yesterday.

SOLVED