1

I'm getting the good old session expired popup every minute in the admin panel which is odd given that memcached should be properly configured:

php.ini

session.auto_start = 0
session.save_handler=memcached
session.save_path="mymemcachedhost:11211"

config/app.php

return [
    'modules' => [
        'my-module' => \modules\Module::class,
    ],
    'components' => [
        'session' => [
            'class' => yii\web\CacheSession::class,
            'as session' => craft\behaviors\SessionBehavior::class
        ],
       'cache' => [
           'class' => yii\caching\MemCache::class,
           'useMemcached' => true,
           'defaultDuration' => 86400,
           'servers' => [
               [
                   'host' => 'mymemcachedhost',
                   'persistent' => true,
                   'port' => 11211,
                   'retryInterval' => 15,
                   'status' => true,
                   'timeout' => 15,
                   'weight' => 1,
               ],
           ]
        ]
    ]
];

/admin/utilities/php-info (craft admin panel)

session.save_handler    user
session.save_path   mymemcachedhost:11211

I think the problem might lay with session.save_handler showing up as user in the craft admin panel for the php.ini but if I look at <?php phpinfo(); ?> on either host behind the loadbalancer I see session.save_handler showing up correctly as memcached.

I've verified with telnet and nc that the memcached host responds correctly at the given host:port combo. Any ideas?

EDIT

The same problem persists when using redis as a session store:

redis attempt config/app.php

<?php
return [
    'components' => [
        'redis' => [
            'class' => yii\redis\Connection::class,
            'port' => 6379,
            'hostname' => 'elasticachehostname'
        ],
        'cache' => [
            'class' => yii\redis\Cache::class,
            'defaultDuration' => 86400,
            'keyPrefix' => 'pm_key',
        ],
        'session' => [
            'class' => yii\redis\Session::class,
            'as session' => craft\behaviors\SessionBehavior::class,
        ],
    ]
];

"yiisoft/yii2-redis": "2.0", has been added to composer With this config I cannot even sign into the admin panel as I get this error in the craft logs (about a dozen times right after another):

2019-11-27 14:43:50 [-][5615][-][error][yii\web\Session::open] session_start(): Failed to read session data: user (path: tcp://elasticachehostname:6379)

Redis is working in php though as I can run this php file no problem (with properly incrementing numbers:

<?php

 ini_set('session.save_handler', 'redis');
 ini_set('session.save_path', 'tcp://elasticachehostname:6379');

session_name('FOOBAR');
session_start();

if (!array_key_exists('visit', $_SESSION)) {
    $_SESSION['visit'] = 0;
}
$_SESSION['visit']++;

echo nl2br(
    'You have been here ' . $_SESSION['visit'] . ' times.'
);

This would indicate that there is definitely an issue on the craft/yii side of things. I don't know why it cannot connect to it.

I also confirmed it's not a Amazon issue, I installed redis locally on the host and get the same error message (except of course tcp://localhost...)

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.