Degp
Degp

Reputation: 43

Codeigniter session error in Redis using PHP 7.0

I am using CI version 3.0.3, PHP version 7.0, Redis and MariaDB. When I store session data in the Database, there are no errors. But if I switch to Redis, I get an error every time session tries to regenerate via session_regenerate_id, in my case every 300 sec. But if I refresh the page again, Redis get updated and page loads without errors.

A PHP Error was encountered

Severity: 4096

Message: session_regenerate_id(): Failed to create(read) session ID: user (path: tcp://localhost:6379?auth=xxxx)

Filename: Session/Session.php

Line Number: 625

Upvotes: 1

Views: 2398

Answers (2)

Degp
Degp

Reputation: 43

Please refer https://github.com/bcit-ci/CodeIgniter/commit/79b8a086187f199bb708bd56477850fbf1dd9e91 for the fix on CI 3.0.3

CI 3.0.4 will ship with the update for PHP 7 out of the box.

Thanks to https://github.com/narfbg

Upvotes: 0

Audren
Audren

Reputation: 1

This is a php / memcached bug related.

Work around:

class MemcachedSession extends SessionHandler { public function read($session_id) { return (string)parent::read($session_id); } }

$sess = new MemcachedSession(); session_set_save_handler($sess, true);

session_start(); $_SESSION['value'] = session_id(); session_regenerate_id(); ?>

Upvotes: 0

Related Questions