yii2-redis: session_regenerate_id(): Session object destruction failed. ID: user (path: )

This issue has originally been reported by @EvgenyOrekhov at https://github.com/yiisoft/yii2/issues/12821. Moved here by @samdark.


session_regenerate_id(): Session object destruction failed. ID: user (path: ) after upgrade to 2.0.10.

What steps will reproduce the problem?

  1. Add this component config:

    'session' => [
        'class' => 'yii\redis\Session',
        'redis' => [
            'hostname' => 'localhost',
        ],
        'timeout' => 10,
    ],
    
  2. Log in to the application.

  3. Wait 10 seconds.

  4. Refresh the application page.

What is the expected result?

No warning.

What do you get instead?

PHP Warning – yii\base\ErrorException

session_regenerate_id(): Session object destruction failed. ID: user (path: )

  1. in vendor/yiisoft/yii2/web/Session.php at line 282
     * 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); // <-- line 282
            } else {
                @session_regenerate_id($deleteOldSession);
            }
        }
    }

Additional info

Q A
Yii version 2.0.10
PHP version 7.0.12
Operating system Alpine Linux 3.4

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Session was removed via TTL redis param, so when you destroy session, DEL command returns false. And false interpeted as a failed session destruction.