PHP 8.6 Makes Session Cookies Secure by Default, but an Old php.ini Template Can Silently Cancel the Change
PHP 8.6, released November 19, ships three session-cookie defaults hardened under a core developer's RFC. An independent developer's analysis finds the hardening only takes effect if nothing overrides it, and PHP's own packaged php.ini templates are one of the things that can.
Background
PHP 8.6 shipped on November 19, 2026, on the project’s usual yearly cadence, with a tagline of “Faster, Safer, More Powerful” and a feature list led by Partial Function Application, a new \Time\Duration class, a scalable Io\Poll I/O-multiplexing API, a clamp() function, and a SortDirection enum, according to the official release announcement. Those additions arrive alongside a quieter change to how PHP handles session cookies out of the box — one whose practical effect depends less on the new version number than on which configuration file a server actually loads.
The session change traces back to a “Secure Session Configuration Defaults” RFC that core developer Jörg Sowa dated April 4, 2026, months before PHP’s codebase came under the scrutiny it saw this past October, when The Register reports that “a swarm of unearthed vulnerabilities has plagued PHP since October, allowing unauthenticated attackers to crash PHP workers or execute arbitrary code on the server,” forcing users of PHP-based software including WordPress, Laravel, and Symfony to update. The Machine Herald previously reported on two of those critical remote-code-execution flaws. The Register writes that the PHP core community and the PHP Foundation “responded with a coordinated release of patched versions of PHP (8.5.13, 8.4.28, 8.3.37, 8.2.36 and the new 8.6) that closed seven critical remote code execution (RCE) flaws in one sweep” — a separate matter from Sowa’s session-defaults RFC, which had already been drafted and targeted at PHP 8.6 months before that wave began.
Sowa’s RFC targeted three ini settings — session.use_strict_mode, session.cookie_httponly, and session.cookie_samesite — which, the RFC states, “have security implications but ship with defaults that leave applications unnecessarily exposed.” The RFC passed “without a single vote against, with one separate vote per setting,” according to a blog post by software engineer Rajekevin Dourepoulle, and all three changes landed in 8.6 proper: the release announcement confirms that “Sessions are now more secure by default: session.use_strict_mode and session.cookie_httponly are enabled, and session.cookie_samesite is set to Lax.”
Current situation
Each of the three settings closes a different gap. session.use_strict_mode, previously off, addresses session fixation, which the RFC defines as allowing an attacker “to pre-plant a known session ID and wait for a victim to authenticate against it,” relying on the fact that PHP would accept any well-formed session ID handed to it without checking that the ID already existed in storage. With the setting now on by default, Sowa writes that “the built-in files handler checks whether a session file for that ID exists on disk; because an attacker-planted ID has no corresponding file, a fresh random ID is generated instead.”
session.cookie_httponly, also now on by default, adds the HttpOnly flag to the session cookie, which The Register describes as “blocking client-side JavaScript from reading the session ID, which could otherwise be stolen to masquerade as the user.” And session.cookie_samesite, which previously shipped empty, now defaults to Lax, meaning the server withholds the session cookie on cross-site requests except top-level navigations using safe methods. The RFC frames the risk this closes directly: “Without it, a forged form or link on an attacker-controlled site can trigger authenticated requests using the victim’s session.”
Taken together, the three changes move PHP’s session handling from opt-in security to secure-by-default, matching a direction browser vendors have already taken with cookies generally. But that description applies to a specific, narrower layer than the PHP version number: it describes the compiled-in defaults a fresh PHP build uses when nothing else sets those three values. What a given server actually serves depends on everything downstream of that default — and that is where the practical rollout gets more complicated.
Implications
Dourepoulle’s analysis, published shortly before the November 19 release, traces the gap between the new default and what many deployments will actually run. The compiled default is one layer; PHP’s own shipped configuration files are another, and they do not automatically track the compiled default. Comparing the php.ini-production template files from the two branches, Dourepoulle found that PHP 8.5’s version “explicitly sets the old values” — session.use_strict_mode = 0, with cookie_httponly and cookie_samesite left blank — while “PHP 8.6’s version has been aligned with the RFC,” setting all three explicitly to their new, secure values.
The consequence, in Dourepoulle’s words: “if your deployment reuses the old php.ini (an Ansible template, a COPY php.ini in a Dockerfile, a file copied from server to server), you move to 8.6 and gain nothing, because the explicit session.use_strict_mode = 0 line overrides the new default.” Because an explicit setting in a loaded php.ini always takes precedence over PHP’s compiled-in default, a server that upgrades its PHP binary to 8.6 while continuing to load a configuration file carried over from 8.5 — or from any earlier version, or built from an old Docker layer, or templated by infrastructure-as-code tooling that predates the RFC — keeps the old, less secure session behavior with no warning or error. The Register summarizes the same finding, attributing it to Dourepoulle, and adds: “For administrators, this PHP update round may be a bit of a shambles.”
The inverse case fares better: Dourepoulle notes that “the official php Docker image enables no php.ini until you copy one of the two templates it ships,” so a server that runs the stock image’s compiled-in defaults without ever installing a custom php.ini picks up the new, secure settings automatically on 8.6. The outcome for any given server therefore hinges on a detail that has nothing to do with the PHP version number: whether its configuration pipeline re-applies an old file or lets the new compiled default stand.
Framework-level behavior adds another layer of variation. According to Dourepoulle’s post, Symfony is largely unaffected by the change either way, because its NativeSessionStorage component “forces use_strict_mode to 1 in its constructor, whatever php.ini says,” and its FrameworkBundle separately applies cookie_httponly: true and cookie_samesite: lax defaults at runtime — meaning Symfony applications already ran with the hardened settings before 8.6 existed, with two exceptions Dourepoulle names: a framework.yaml that explicitly disables them, or legacy code that calls session_start() directly outside Symfony’s session service. Laravel, per Dourepoulle’s post, manages its own session cookies separately from PHP’s native session handling, so “most applications won’t see a thing” from the ini change either way.
For applications that do rely on PHP’s native session defaults, Dourepoulle’s post describes one further, narrower trade-off from the SameSite=Lax change: cross-site POST requests — his examples are a payment provider returning a user via POST, SAML single sign-on, and forms submitted from another domain — arrive without the session cookie once the new default is in effect. Dourepoulle writes: “No error shows up; the user is just logged out.” His proposed fix is not to loosen the setting back to SameSite=None, which the RFC itself notes requires session.cookie_secure to also be set, but to restructure the flow so the session is not read during the cross-site POST itself.
To check which configuration is actually in effect, Dourepoulle’s post lists three shell commands — checking PHP’s compiled defaults directly, checking the values PHP-FPM or the CLI will actually load, and inspecting the Set-Cookie header PHP sends on a live request — and notes that only the last of the three is authoritative for production web traffic, since “the CLI and PHP-FPM often read different php.ini files.” Whether PHP 8.6’s security-by-default change reaches a given application, in other words, is a question the new version number alone cannot answer.