PHP 8.6 has been released with security-focused default changes intended to reduce common session-management risks and make certain programming errors more visible to developers.
The update follows a recent round of security patches affecting multiple supported PHP branches. The PHP project and PHP Foundation issued updates for versions 8.2 through 8.5 alongside the new 8.6 release, addressing several reported vulnerabilities, including flaws that could enable remote code execution in affected environments.
Session protections enabled by default
PHP 8.6 changes defaults in the session extension that previously required administrators or application developers to opt in. Session strict mode is now enabled by default, meaning PHP will reject externally supplied session identifiers that do not correspond to sessions it created. This is designed to limit session fixation attacks, in which an attacker attempts to make a victim use a known session ID.
Session cookies will also receive the HttpOnly attribute by default, preventing browser-based JavaScript from accessing them. That can reduce the impact of some cross-site scripting incidents where attackers try to steal session tokens.
In addition, PHP applies a more restrictive SameSite policy to session cookies. Cookies will generally not be included with cross-site POST requests, embedded frames, or subrequests, helping to mitigate cross-site request forgery attacks. They remain available for same-site activity and top-level GET navigation.
More explicit failures
The release also tightens handling of strings containing null bytes. In situations where PHP previously accepted such values silently, it may now raise an error. Null-byte handling has historically caused inconsistencies when PHP code passes strings to underlying C libraries, which treat a null character as a string terminator.
Other functions have been adjusted to report unsuccessful operations more clearly. For example, some file-closing and data-copying operations will return false when they fail or end prematurely, giving applications an opportunity to detect integrity problems.
Deployment considerations
Administrators should verify their effective configuration after upgrading. Existing php.ini files, container images, automation templates, frameworks, and application-level settings can explicitly retain older values and override PHP 8.6 defaults. Organizations should review session-related configuration, test applications for compatibility, and continue applying supported PHP security updates promptly.
PHP 8.6 also adds developer-oriented features, including partial function application, a polling API for event-driven workloads, a Duration class, and a clamp() utility.
