yii2: session_regenerate_id(): Failed to create(read) session ID: memcache (path: 11.11.11.11:1111)

My environment:php7.0.x yii2-2.0.10

I installed php7 and wrote session data to Memcache, and I made sure that the corresponding extensions were installed, either Memcache or Memcached. I get one of the following errors:

PHP Recoverable Error – yii\base\ErrorException
session_regenerate_id(): Failed to create(read) session ID: memcache (path: 11.11.11.11:1111)

The following is the code area where the error occurred:

/**
     * Updates the current session ID with a newly generated one .
     * Please refer to <http://php.net/session_regenerate_id> for more details.
     * @param boolean $deleteOldSession Whether to delete the old associated session file or not.
     */
    public function regenerateID($deleteOldSession = false)
    {
        if ($this->getIsActive()) {
            // add @ to inhibit possible warning due to race condition
            // https://github.com/yiisoft/yii2/pull/1812
            if (YII_DEBUG && !headers_sent()) {
                session_regenerate_id($deleteOldSession);
            } else {
                @session_regenerate_id($deleteOldSession);
            }
        }
    }

The strange question bothered me, I created the test file, simply used the session, including the write or read, everything was normal. I have to doubt that the framework of the problem, suspected frame using the expired function. But all this hope to get your confirmation.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (12 by maintainers)

Most upvoted comments

Seems like you need to upgrade memcached.

This bug was openned with PHP.net about it: https://bugs.php.net/bug.php?id=71187

They identified that the issue was with the memcached code and they opened this pull request and closed the bug report. https://github.com/php-memcached-dev/php-memcached/pull/164

The pull request was merged on January 20th so presumably this is available since version 3.0.0 where they mention “Fixes crash with session_regenerate_id (work-around for PHP bug)”. https://github.com/php-memcached-dev/php-memcached/releases/tag/v3.0.0

@samdark Mail(sam@rmcreative.ru) has been sent, please pay attention to check.