PHP 8.6.0 is planned for general availability on 19 November 2026, according to the php.net release announcements. One of the changes most likely to affect plain PHP apps is not a new syntax feature at all. It is three new default values in the session extension, from the accepted RFC Secure Session Configuration Defaults.

If your app calls session_start() and never configured these settings, its session cookie will behave differently after the upgrade. This guide explains each change, who it can break, and how to test it today on your current PHP version.

The three new defaults

INI setting Old default New default in PHP 8.6
session.use_strict_mode 0 1
session.cookie_httponly 0 1
session.cookie_samesite not set Lax

The RFC was accepted with no votes against. Each change is a one-line edit in ext/session/session.c. No new ini entries, functions or constants are added.

Important: these are compiled-in defaults. If your php.ini, .user.ini, pool config or code already sets a value, that value still wins. The change only affects settings you never set.

1. Strict mode: unknown session IDs are rejected

With use_strict_mode=0, session_start() accepts any well-formed session ID from a cookie, $_GET or $_POST, even if no such session exists. That allows session fixation: an attacker plants a known ID, the victim logs in, and the attacker now shares the session.

With use_strict_mode=1, PHP validates the ID first. The built-in files handler checks that a session file exists. If it does not, PHP issues a fresh random ID.

Who can break: apps that hand a session ID to another system on purpose, for example a shared-secret hand-off between subdomains using the files handler. The receiving side now rejects the ID if the session was not saved yet. The RFC’s fix is to write and close the session on the originating side first:

<?php
session_start();
$_SESSION['user_id'] = $userId;
$sid = session_id();
session_write_close(); // make sure the session exists in storage

header('Location: https://app.example.com/sso?sid=' . urlencode($sid));

The RFC notes that custom handlers whose validateId() always returns true are unaffected. That includes the default phpredis and php-memcached session handlers, which do not implement validateId().

2. HttpOnly: JavaScript can no longer read the session cookie

HttpOnly tells the browser to hide a cookie from document.cookie. Injected scripts from an XSS bug cannot read or steal it. The cookie is still sent with requests as usual.

Who can break: front-end code that reads the session ID from document.cookie, for example to put it into a custom header. That stops working. The RFC’s advice: the session ID is a server-side credential and should never be used by client code. Use a separate, non-HttpOnly CSRF token instead:

<?php
session_start();

if (empty($_SESSION['csrf'])) {
    $_SESSION['csrf'] = bin2hex(random_bytes(32));
}
?>
<meta name="csrf-token" content="<?= htmlspecialchars($_SESSION['csrf'], ENT_QUOTES) ?>">
const token = document.querySelector('meta[name="csrf-token"]').content;

fetch('/api/orders', {
  method: 'POST',
  headers: { 'X-CSRF-Token': token, 'Content-Type': 'application/json' },
  body: JSON.stringify({ item: 42 }),
});

3. SameSite=Lax: no session cookie on cross-site POSTs

With SameSite=Lax, the browser sends the session cookie on same-site requests and on top-level cross-site navigations using safe methods (GET, HEAD). It does not send it on cross-site POST requests or cross-site sub-resource requests. That blocks a large class of CSRF attacks.

Chrome (since version 80) and Firefox already treat cookies without a SameSite attribute as Lax. The RFC points out that Safari does not apply that implicit default, so setting it explicitly in PHP makes behaviour consistent across browsers.

Who can break: flows that rely on a cross-site POST carrying the session, such as SP-initiated SAML SSO where the identity provider posts back to your site, legacy cross-origin form submissions, and some payment-gateway callbacks that POST to a page expecting the user’s session. Those endpoints need SameSite=None; Secure explicitly, or a token-based flow.

You can set the cookie options per request before starting the session:

<?php
// Only on the SAML assertion consumer endpoint
session_set_cookie_params([
    'samesite' => 'None',
    'secure'   => true,   // required with SameSite=None
    'httponly' => true,
]);
session_start();

Test the new behaviour now, before upgrading

You do not need PHP 8.6 to see the effect. Set the new values explicitly on PHP 8.4 or 8.5 in a staging environment:

; php.ini or conf.d/99-session-test.ini
session.use_strict_mode = 1
session.cookie_httponly = 1
session.cookie_samesite = Lax

Then check what is actually in effect:

php -i | grep -E "session\.(use_strict_mode|cookie_httponly|cookie_samesite)"

For PHP-FPM, check from a web request instead, since the CLI can read a different ini file:

<?php
foreach (['session.use_strict_mode', 'session.cookie_httponly', 'session.cookie_samesite'] as $key) {
    printf("%s = %s\n", $key, var_export(ini_get($key), true));
}

Finally, look at the real cookie header:

curl -sI https://staging.example.com/login | grep -i set-cookie
# Expect something like: Set-Cookie: PHPSESSID=...; path=/; HttpOnly; SameSite=Lax

A quick test plan

  1. Log in, log out and log in again in each major browser.
  2. Run any SSO, OAuth or SAML login end to end.
  3. Run payment flows that redirect away and back, especially ones that POST back.
  4. Check embedded pages (iframes on other domains) that need a logged-in session.
  5. Search your JavaScript for document.cookie and PHPSESSID.
  6. Check subdomain hand-offs that pass a session ID in a URL.
grep -rnE "document\.cookie|PHPSESSID" resources/ public/ src/ 2>/dev/null

What about frameworks?

The RFC’s comparison table notes that Laravel and Symfony already default to HttpOnly and SameSite=Lax for their session cookies. Apps on those frameworks are unlikely to notice the cookie changes, but strict mode can still matter if you use native PHP sessions anywhere, such as in legacy scripts or admin tools.

Can I keep the old behaviour?

Yes, by setting the old values explicitly. But treat that as a short-term exception for the specific endpoint that needs it, not a global setting. All three new defaults close real attack paths: session fixation, cookie theft through XSS and cross-site request forgery.

Takeaway

PHP 8.6 makes native sessions secure by default: strict session IDs, HttpOnly cookies and SameSite=Lax. Most apps will not notice anything except better security. If you run SSO, cross-site POST callbacks or JavaScript that reads the session cookie, set the new values on staging now and fix those flows before you upgrade.