Skip to content

Previous create_sid handler remains active when not explicitly overridden #21193

@TimWolla

Description

@TimWolla

Description

The following code:

<?php

ob_start();

session_set_save_handler(
	function ($savePath, $sessionName) {
		var_dump("open");

		return true;
	},
	function () {
		var_dump("close");

		return true;
	},
	function ($id) {
		var_dump("read");

		return '';
	},
	function ($id, $data) {
		var_dump("write");

		return true;
	},
	function ($id) {
		var_dump("destroy");

		return true;
	},
	function ($maxlifetime) {
		var_dump("gc");

		return true;
	},
	function () {
		var_dump("create_sid");

		return 'foo';
	}
);

session_set_save_handler(
	function ($savePath, $sessionName) {
		var_dump("open");

		return true;
	},
	function () {
		var_dump("close");

		return true;
	},
	function ($id) {
		var_dump("read");

		return '';
	},
	function ($id, $data) {
		var_dump("write");

		return true;
	},
	function ($id) {
		var_dump("destroy");

		return true;
	},
	function ($maxlifetime) {
		var_dump("gc");

		return true;
	},
);

session_start();

Resulted in this output:

string(4) "open"
string(10) "create_sid"
string(4) "read"
string(5) "write"
string(5) "close"

But I expected this output instead:

string(4) "open"
string(4) "read"
string(5) "write"
string(5) "close"

PHP Version

PHP 8.4.17 (cli) (built: Jan 18 2026 14:19:44) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.17, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.17, Copyright (c), by Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions