Skip to content

RedisSession::start() Fatal Error #3

@jordm

Description

@jordm

On PHP 8.1 I am getting issues connecting to redis through RedisSession

start-session.php:

// this must match the express-session `secret` in your Express app
define('EXPRESS_SECRET', 'test');

// this id mutator function helps ensure we look up
// the session using the right id
define('REDIS_SESSION_PREFIX', 'PHPREDIS_SESSION:');

...

require_once("redis-session-php/redis-session.php");

// Test PredisClient connection
$client = new Predis\Client([
	"scheme" => "tcp",
	"host" => "host.docker.internal",
	"port" => 6379,
	"password" => "test"
]);

$client->set("foo", "bar");

RedisSession::start([
	"scheme" => "tcp",
	"host" => "host.docker.internal",
	"port" => 6379,
	"password" => "test"
]);

$_SESSION["php"] = "Hello from PHP";
if (!isset($_SESSION["cookie"]))
  $_SESSION["cookie"] = array();

Looking at redis-cli, the output is:;

127.0.0.1:6379> keys *
1) "foo"

I'm getting the following error when running RedisSession::start():

php-dev    | NOTICE: PHP message: PHP Fatal error:  Uncaught TypeError: Session callback must have a return value of type bool, null returned in /var/www/php/src/redis-session-php/redis-session.php:47
php-dev    | Stack trace:
php-dev    | #0 /var/www/php/src/redis-session-php/redis-session.php(47): session_start()
php-dev    | #1 /var/www/php/src/start-session.php(55): RedisSession::start()
php-dev    | #2 /var/www/public/index.php(4): require_once('/var/www/php/sr...')
php-dev    | #3 {main}
php-dev    |   thrown in /var/www/php/src/redis-session-php/redis-session.php on line 47

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions