XF 2.1 Admin login issue v2.1.3

sajal

Active member
We are facing strange issue in admin login. After login to admin side, access 1 to 2 pages, it again shows login page. When pressing Ctrl + R couple of times it again shows logged in.

Can anyone help what's the exact issue? Why it shows admin page again after login?

Here's my config.php:

PHP:
<?php
$config['db']['host'] = 'XXXX';
$config['db']['port'] = '3306';
$config['db']['username'] = 'XXXX';
$config['db']['password'] = 'XXXX';
$config['db']['dbname'] = 'XXXX';

$config['cookie']['prefix'] = 'XXXX_';
$config['cookie']['path'] = '/';
$config['cookie']['domain'] = '.XXX.XXX.com';

$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'host' => 'XXXX',
    'port' => '6379'
];
$config['cache']['namespace'] = 'XXXX_';
$config['enableMail'] = false;
$config['superAdmins'] = '1';
$config['enableAddOnArchiveInstaller'] = true;
$config['development']['enabled'] = true;
 
There are a couple of scenarios where you might be asked to log in again. One of them is if a new session is generated for some reason, and one is if your IP address changes (which also causes a new session to be created).

In the first instance I'd probably comment out any of the cache settings to see if that changes anything.

Otherwise, it's likely to be your IP address changing. Your IP address can change frequently if you are using a VPN, or your site is proxied through something like CloudFlare, or even sometimes through data saving features in your browser.

In some proxy situations, mostly CloudFlare and Google, we attempt to resolve your proxied IP address back to your original IP address automatically. But given that you're using an old and unsupported version of XF, it may be that we aren't correctly converting your IP address to the correct one so it may appear to be sporadically changing.

Are you using CloudFlare or something similar?
 
Yeah so you'll probably want to add the following to your src/config.php file:

PHP:
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}

Although if you were able to update to the latest version of XF 2.2 then it would probably be resolved automatically as we maintain a current list of CloudFlare IP addresses and try to restore the normal IP address automatically.
 
Top Bottom