We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Redis Session not destroyed

Hi all,

I'm have some troubles with redis session when I'm trying to destroy it.

Configuration (Virtualbox with 4 VM) :

HTTP Server

  • nginx v1.10.2
  • PHP Version 7.0.13-1~dotdeb+8.1
  • Phalcon 3.0.2

Cache Server

  • Redis v3.2.5

Session Server

  • Redis v3.2.5

Databases Server

  • MariaDB
  • MongoDB

Bootstrap cache setting :

        $cacheConfig = new Config( require ($this->servicesDir . 'cache.php'));

        $this->di->set('cache', function () use ($cacheConfig) {
            $frontCache = new \Phalcon\Cache\Frontend\Data(
                    'lifetime' => $cacheConfig->lifetime

            $cache = new \Phalcon\Cache\Backend\Redis($frontCache, $cacheConfig->redis->toArray());

            return $cache;

Redis cache server works perfectly with cache settings (maxmemory ans momemry-policy) and AUTH.

Then i'm using session with another redis server (normal settings), I try using session but it's seems when i'm using destroy function, it doesn't work...

Bootstrap session setting :

        $cacheConfig = new Config( require ($this->servicesDir . 'session.php'));
        $this->di->set('session', function () use ($cacheConfig) {
            $session = new \Phalcon\Session\Adapter\Redis($cacheConfig->toArray());
            return $session;

Test used :

        $this->session->set('foo', 'Bar');
        echo $this->session->get('foo');  // OK

        $this->session->set('product', ['name' => 'ipad', 'price' => '299.90€']);   
        var_dump($this->session->get('product'));  // OK


        echo $this->session->get('foo');  // data not destroyed
        var_dump($this->session->get('product'));  // data not destroyed

Data not deleted on remote server.

Any Idea why session destroy not work ?



This may be the same case as an older question:

Destroy the session does not remove data from the $_SESSION superglobal



It means "destroy" method is useless if we hate to use PHP super-global $_SESSION.

I hape there is a solution instead using :


I hope there is a solution for making clean code.

Thx for reply.