PHP 8.6 Finally Turns On the Session Settings You Were Told to Set in 2006
Every PHP hardening guide for two decades has told you to flip the same three session settings. PHP 8.6, due November 19, 2026, flips them for you: strict mode on, HttpOnly on, SameSite set to Lax.
PHP has supported the HttpOnly flag on session cookies since version 5.2, which shipped in 2006. For the twenty years since, it has been off by default. Strict session mode, the setting that stops session fixation, has been off since the day it was added. SameSite has been unset. Every hardening checklist has had the same three lines in it, and every fresh install has needed someone to read the checklist.
PHP 8.6 ends that. The release is scheduled for Thursday, November 19, 2026, and the seventh release candidate went out on November 12. Most coverage will lead with partial function application, which is a nice piece of syntax. The changes that matter more for anything facing the internet are further down the upgrade notes: three session defaults, a limit on php://filter chains, a tighter rule for Phar files, and a new way to quote strings for MySQL.
What's New in PHP 8.6
The short version, from the UPGRADING file in the PHP 8.6 branch:
| Change | What it does | Can it break you? |
|---|---|---|
| Secure session defaults | Strict mode, HttpOnly, and SameSite=Lax are on |
Yes, if you depended on the old behavior |
php://filter chain limit |
More than 16 filters in one URL is deprecated | Only if you chain that many |
| Phar detection | .phar must be the file's extension |
Rarely |
mysqli::quote_string() |
Escapes and quotes in one call | No, it's new |
| Sodium additions | ML-KEM768, X-Wing, SHAKE, ipcrypt | No |
| Partial function application | ? placeholders create closures |
No |
clamp(), Time\Duration, polling API |
New function, class, and I/O API | No |
Three Session Defaults, Twenty Years Late
Here is what the session extension reports on PHP 8.3.6, which is what my test machine runs. This is my own one-liner, using ini_get() with no php.ini loaded:
foreach (["session.use_strict_mode", "session.cookie_httponly", "session.cookie_samesite"] as $k) {
printf("%s = %s\n", $k, var_export(ini_get($k), true));
}
session.use_strict_mode = '0'
session.cookie_httponly = '0'
session.cookie_samesite = ''
Those are the defaults PHP has shipped for years. PHP 8.6 changes all three:
| Setting | Before | PHP 8.6 | What it stops |
|---|---|---|---|
session.use_strict_mode |
0 |
1 |
Session fixation |
session.cookie_httponly |
0 |
1 |
Scripts reading the session cookie |
session.cookie_samesite |
unset | Lax |
Session cookies riding on cross-site POSTs |
Strict mode is the one people skip, so it's worth a sentence. With it off, session_start() accepts any well-formed session ID a client supplies and starts a session under it. An attacker plants a known ID in a victim's browser, waits for the victim to log in, and then uses the same ID. With strict mode on, PHP checks that the ID already exists in storage and issues a fresh random one if it doesn't.
The RFC's author, Jorg Sowa, included a comparison that explains why this passed. ASP.NET Core and Django already default to HttpOnly and SameSite=Lax. PHP defaulted to neither. On HttpOnly, the RFC is blunt: "There is no legitimate reason to default it to off."
These are behavior changes, and the RFC lists who gets hurt:
- Strict mode. Apps that hand a session ID from one subdomain to another before the session file exists will have the ID rejected. Custom handlers that don't implement
validateId()are unaffected, which the RFC says covers the default Redis and Memcached handlers. - HttpOnly. JavaScript that reads the session cookie from
document.cookiestops working. The RFC's advice is to use a separate CSRF token and leave the session ID to the server. - SameSite=Lax. Cross-site POSTs no longer carry the session cookie. The RFC names SP-initiated SAML SSO flows as the likely casualty. Those endpoints need
SameSite=NonewithSecure, set explicitly.
If your php.ini or framework already sets these, nothing changes. Laravel, for one, has set its own values for years. The people this helps are the ones running plain PHP with the defaults, who are also the people least likely to have read a hardening guide.
We recommend reading How Authentication Actually Works to continue reading our selection of content. Sessions are one of the mechanisms it walks through, including what the cookie is for and what goes wrong when it leaks.
How Authentication Actually Works Authentication explained step by step: authentication vs authorization, password hashing, sessions, tokens, JWTs, OAuth and MFA in web apps. SudoSecurity · Landen
The php://filter Chain Limit
This one closes a door that attackers have been walking through for years.
PHP stream filters transform data as it's read: base64, character-set conversion, case changes. You can chain them in a php://filter URL. The problem, as the RFC by Sjoerd Langkemper puts it, is that with enough filters "it is possible to transform any content, such as an empty resource, into any other content, such as a webshell." A local file inclusion bug like include $_GET['a'] is supposed to be limited to files already on the disk. Filter chains remove that limit. The attacker doesn't need to upload anything, because the chain manufactures the payload.
The RFC gives filter counts for known attacks, and they explain where the number 16 comes from:
| Filters | What the chain does |
|---|---|
| 1 | Returns a PHP file's source instead of running it |
| 5 | Error oracle: tells whether a file starts with a hex character |
| 11 | Exploits an iconv vulnerability |
| 47 | Prepends %PDF to /etc/passwd to pass format checks |
| More than 50 | Error oracle that leaks a file's contents |
| More than 100 | Produces a webshell |
Legitimate use looks nothing like that. The RFC's survey of open-source code found that almost every real php://filter URL uses one filter, occasionally two.
PHP 8.6 sets the limit at 16 and adds a stream context option, filter.max_filter_count, to change it. Normal use is untouched. This example from the RFC still works, and I confirmed the output on PHP 8.3.6:
var_dump(file_get_contents("php://filter/string.toupper|string.rot13/resource=data://text/plain,hello"));
// string(5) "URYYB"
The important detail is that 8.6 does not block long chains by default. Going over 16 emits a deprecation warning and still runs. The hard failure comes only when the option is set, or in a later PHP version. The RFC shows the failure with a limit of one:
$ctx = stream_context_create(['filter' => ['max_filter_count' => 1]]);
var_dump(file_get_contents("php://filter/string.toupper|string.rot13/resource=data://text/plain,hello", false, $ctx));
// Warning: file_get_contents(php://filter/string.toupper|string.rot13/resource=data://text/plain,hello): Failed to open stream: too many filters in ...
// bool(false)
So if you want the protection on the day you upgrade, set the limit yourself. The RFC raises it globally with stream_context_set_default(['filter' => ['max_filter_count' => 1000]]);. The same call with a low number turns the deprecation into a refusal for every php://filter URL that uses the default context. Code that really needs many filters can still stack them with stream_filter_append(), which the limit doesn't touch.
Per the RFC's own table, a limit of 16 stops the webshell and file-leak chains but not the shorter ones. An inclusion bug is still an inclusion bug. This takes away its worst outcome.
Phar Files Have to Look Like Phar Files
A smaller change in the same spirit. PHP treats some included files as Phar archives automatically. Until now, .phar could appear anywhere in the path: a directory name, or part of a longer extension like .pharma. In 8.6, a file is only auto-detected as a Phar when .phar is an extension in the filename itself. That removes one way to get PHP to parse an attacker-influenced file as an archive.
mysqli::quote_string()
Prepared statements are the answer to SQL injection, and that hasn't changed. But some code has to build literal SQL. The RFC's example is phpMyAdmin, which shows complete queries to the user.
For that code, mysqli has only offered real_escape_string(), which escapes a value and leaves the quoting to you:
$sql = sprintf("SELECT '%s'", $mysqli->real_escape_string($value));
$sql = sprintf('SELECT "%s"', $mysqli->real_escape_string($value));
Forget the quotes and the escaping protects nothing. Use double quotes and, per the RFC, you hit "a well-known SQL injection vulnerability." The new method does both steps and always uses single quotes, the way PDO::quote() does:
"'Don\\'t!'" === $link->quote_string("Don't!");
The RFC's author, Kamil Tekiela, says it "should fix the last remaining SQL injection loophole" in the extension. It doesn't make string-built SQL a good idea. It removes one way to get it wrong.
New Cryptography
Four additions matter if you write or maintain crypto code:
- Post-quantum key exchange. Sodium gains
sodium_crypto_kem_*functions exposing X-Wing, a hybrid of ML-KEM768 and X25519 that the upgrade notes call "libsodium's recommended KEM," plus ML-KEM768 (FIPS 203) on its own. Both need libsodium 1.0.22 or later. gmp_powm_sec(). Modular exponentiation that is "side-channel quiet." As RSA in Python - Preventing Side Channel Attacks explains, this is the operation that leaks, and the function exists so it doesn't. It isn't available on official Windows builds.- TLS for streams. Session resumption, external pre-shared keys, and TLS 1.3 early data are now reachable through stream context options.
- SHAKE and TurboSHAKE extendable-output functions, and
ipcryptfor encrypting IP addresses.
There is one related fix in SOAP. When SoapClient imports a WSDL from a different host than the original, it now redacts the Authorization, Proxy-Authorization, and Cookie headers by default.
We recommend reading php2shell: The PHP Bug That Fires Before Your Code Runs to continue reading our selection of content. Secure defaults protect the code you write, and that piece covers the kind of PHP flaw that sits underneath it.
php2shell: The PHP Bug That Fires Before Your Code Runs php2shell (CVE-2026-109618/109619) is a 9.2 PHP RCE firing during request setup, before your code runs. Versions, mitigations, KEV status. SudoSecurity · Santhdium
The Syntax Everyone Else Will Lead With
Partial function application. Replace an argument with ? and you get a closure instead of a call. The RFC, by Larry Garfield and Arnaud Le Blanc, shows the before:
$result = array_map(static fn(string $string): string => str_replace('hello', 'hi', $string), $arr);
And the after:
$result = array_map(str_replace('hello', 'hi', ?), $arr);
It also costs nothing at runtime in the common case. The upgrade notes say array_map() with a partial application or first-class callable is compiled into the equivalent foreach loop.
clamp(). It returns the value if it's in range and the nearest bound if it isn't. From the RFC:
clamp(2, min: 1, max: 3) // 2
clamp(0, min: 1, max: 3) // 1
clamp(6, min: 1, max: 3) // 3
It throws a ValueError if $min is greater than $max, which is the check hand-rolled versions tend to skip.
The rest. Readonly properties can declare default values. Time\Duration is a new class for spans of time. There's a new polling API under Io\Poll, and a stream errors API that lets you collect stream failures as objects. printf() calls that use only %s and %d are compiled into string interpolation.
What Breaks
Beyond the session defaults, these are the changes most likely to show up in your logs:
| Change | Type |
|---|---|
is_double(), is_long(), is_integer(), doubleval() |
Deprecated |
spl_object_hash() |
Deprecated; use spl_object_id() |
metaphone(), strcoll() |
Deprecated |
| Mbregex | Deprecated, because Oniguruma "is no longer maintained" |
return inside a finally block |
Deprecated |
Returning a value from __construct() or __destruct() |
Deprecated |
More than 16 filters in a php://filter URL |
Deprecated |
NUL bytes in arguments to getenv(), putenv(), parse_str(), and others |
Now a ValueError |
trim() and friends |
Form feed (\f) is now trimmed by default |
By-reference foreach |
May now visit elements it used to skip |
The Mbregex line deserves a second look if you use the mb_ereg family. The library under it has no maintainer, and code that parses untrusted input shouldn't rest on that.
What This Doesn't Cover
This is a reading of the PHP 8.6 UPGRADING file and the RFCs behind the changes, written before general availability. I ran the baseline examples on PHP 8.3.6. I did not run PHP 8.6 itself, so every statement about 8.6 behavior comes from the project's own documents. The release date is the project's target. This cycle already skipped two release candidates, so check php.net before you plan around Thursday.
It isn't a full changelog. The upgrade notes run to several hundred entries across extensions, including SNMP, Intl, URI, and GD work I've left out. It also isn't a migration guide. Run your test suite against a release candidate with deprecations visible before you upgrade production.
The filter-chain section describes a class of attack and the counts the RFC publishes. It contains no chain and no payload.
The Actual Point
Secure defaults matter more than secure options. An option protects the people who know to set it. A default protects everyone else, and for PHP that is a very large number of sites run by people who never opened php.ini.
PHP 8.6 moves three session settings, one filter limit, and one Phar rule from the first group to the second. When you upgrade, check whether anything in your app depended on the old session behavior, set filter.max_filter_count explicitly so long chains fail now instead of in a later version, and grep for real_escape_string to see what can move to quote_string() or, better, a prepared statement.
The session-defaults snippet is original code using PHP's documented ini_get(), run on PHP 8.3.6; its output is reproduced from that run. All other code blocks are reproduced from the PHP RFCs for secure session defaults, the filter chain limit, mysqli::quote_string(), partial function application, and clamp(). The feature list, deprecations, and quoted notes are from the UPGRADING file in the PHP-8.6 branch, and the schedule is from the PHP 8.6 release page, both as of November 14, 2026.
$ tail -f /forums
Discussion
Comments live on the community forums — sign in there to reply.