Upgrading to PHP 8.6: Session Defaults and Deprecations That Will Hit Your App
Scott Keck-Warren • November 20, 2026
If everything went to plan, PHP 8.6 was released yesterday. If you've already upgraded production (which hopefully you didn't cause that's a big risk), you might be having problems with users being bounced back to the login page after being redirected to their SSO provider or failed payment provider POSTs back to the app. Nothing in your code changed, but some core changes happened that might be affecting your codebase.
The Three New Session Defaults
At my day job, security is always at the forefront of my mind. Part of defence in depth means PHP's defaults should be as secure as possible. Every release finds at least one thing to tighten (take that, "PHP isn't secure" people).
To that end, PHP 8.6 changes the default value for three settings:
|Setting|Old Default|New Default|What It Blocks|
|session.use_strict_mode|0|1|session fixation|
|session.cookie_httponly|0|1|JS reading the session cookie (XSS cookie theft)|
|session.cookie_samesite|empty|Lax|cross-site requests carrying the session (CSRF)|
Before we go any further, I want to highlight that this won't affect apps that already set these in php.ini or that have the settings changed via session_set_cookie_params() (maybe through your framework). So if you've upgraded and something is broken, you can override the new defaults.
What Breaks: SameSite=Lax
This is potentially a big one for you if you're using a system that redirects with a cookie. The high-level explanation of it is that Cross-site POSTS will now no longer carry the sessions cookie. This might affect SSO, payment gateway callbacks, and cross-domain form posts. Links will still work using GET, but if you POST the data, it will be missing the cookie when it returns.
sequenceDiagram
autonumber
participant B as Browser
participant A as Your App
participant P as Payment Provider
B->>A: GET /checkout (sends PHPSESSID)
A-->>B: Redirect to payment provider
B->>P: Enter card details
P-->>B: Auto-submit form: POST /payment/callback
B->>A: Cross-site POST /payment/callback
Note over B,A: SameSite=Lax blocks cookie on cross-site POST.<br/>No PHPSESSID sent.
A->>A: session_start() finds no cookie, creates new empty session
A-->>B: User not authenticated, redirect to /login
B->>A: GET /login
Note over B: User logged out mid-checkout
There are two options to fix this (in order of preference):
1. Make the callback endpoint not depend on the session using a signed payload
2. Set SameSite=None; Secure on the cookie for that flow.
There's a low chance of this causing a problem, but not a zero chance, so I would recommend moving away from depending on the session.
What Breaks: HttpOnly and Strict Mode
The other two changes are to the HttpOnly and Strict settings.
With the HttpOnly change, any JavaScript (JS) reading document.cookie for PHPSESSID will stop working. It's an easy fix: stop doing that and pass what JS needs through a data attribute or endpoint. I've honestly never done this, and it seems like it's just a way to leak session information, so again, don't do this.
The Strict mode change causes PHP to reject session IDs it didn't create. This will break setups that are handed the session ID from some external system (custom SSO, a mobile app, load balancer). The fix for this is to create the session first, so it won't get rejected.
How to Check Before You Upgrade
If you're worried about these, there's an easy process you go through to check your code in PHP 8.5:
- Run
php -i | grep sessionin production to see what your current settings are - In staging, set the three new values
- Test login, logout, SSO round trip, and embedded iframe flows
There is an "escape hatch," but I would recommend fixing the issues instead of pulling this escape. That's to alter your php.ini to use the old settings:
session.use_strict_mode = 0
session.cookie_httponly = 0
session.cookie_samesite = ""
The Deprecations You'll Hit
As with all releases, in PHP 8.6 some functions are being deprecated. If you're not careful, these are going to fill up your logs with deprecation notices.
The ones that are a worry are is_integer(), is_long(), is_double(), and doubleval() which have replacements (is_int(), is_float(), floatval()). I found 150 of these in my own project without even really understanding they were "wrong".
To fix them, you can run the following grep command:
grep -rnE --include='*.php' '\b(is_integer|is_long|is_double|doubleval)\(' app/
Or use Rector to fix them in bulk.
I always like to point out that deprecations are warnings, but they will become errors in 9.0. So they're not going to be urgent until they become unavoidable.
For a full list, see https://wiki.php.net/rfc/deprecations_php_8_6
Upgrade Checklist
I'm going to give you a simple upgrade checklist:
- Check your session ini value
- Test cross-site flows
- Grep the aliases
- Run Rector
- Turn on deprecation logging in staging
I have more of my favorite features in my PHP 8.6 roundup. You can watch the video or read the written version.
AI notice
The outline for this post was generated via AI, then I wrote the prose and ran it through Grammarly