XF 1.2 Constantly being asked to login to AdminCP.

Liam W

in memoriam 1998-2020
I'm on 1.2.1 and this is starting to get annoying...

I'm using the AdminCP, change something, click to save or do something and it says it can't be completed as I've been logged out.

It also directs me to the login page when I try and navigate to a different area of the Admin panel.

The admin session cookie is being set, and is set to expire at the end of the browsing session. There's no issue on the front end login, so why is this happening?

My cookie settings are also OK, and it isn't happening on my test (localhost) install.

Liam
 

I'm using CDN Net, if that counts? Otherwise, no.

@Jeremy actually, yes, REMOTE_ADDR is showing the IP of cdnnet. I have a way to (sort of) fix this though, for now at least.

I added this to the bottom of your config.php:

PHP:
function getIp() {
    $ip = $_SERVER['REMOTE_ADDR'];
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    return $ip;
}

$_SERVER['REMOTE_ADDR'] = getIp();

After doing that, my correct IP is shown on the list of online users, as CDN.net adds the other headers.

Obviously, it should be taken with a pinch of salt as headers can be modified, but isn't that the case for the main one as well?

I'll soon see if this fixed the admincp issue :)
 
Last edited:
Back
Top Bottom