Skip to main content
InfoInfo disclosureOWASP A05:2021CWE-200

How to fix: PHP session cookie naming exposes runtime

The PHPSESSID cookie name in the Set-Cookie header reveals that the server-side runtime is PHP. Default framework cookie names act as free fingerprints for attackers performing stack reconnaissance.

Why it matters

Knowing the server uses PHP lets attackers immediately focus on PHP-specific vulnerabilities, version checks, and misconfigurations rather than needing to probe the stack. Combined with an X-Powered-By header or error messages, it narrows the attack surface to PHP CVEs.

PHP sets the session cookie to PHPSESSID by default. This name is universally recognized as a PHP fingerprint. Renaming it to a generic opaque string costs nothing and removes one layer of passive information disclosure.

How to fix it

  1. 1Override the default session cookie name in php.ini: session.name = sid
  2. 2Alternatively, set it at runtime before session_start(): ini_set('session.name', 'sid');
  3. 3Choose a name that does not reference the framework or language.
  4. 4Also set session.cookie_httponly = 1 and session.cookie_secure = 1 in php.ini.

Code examples

PHP (php.ini)

INI
; Rename the session cookie to a generic opaque name
session.name = sid
session.cookie_httponly = 1
session.cookie_secure = 1
session.cookie_samesite = Strict

PHP (runtime, before session_start)

PHP
// Set before calling session_start()
ini_set('session.name', 'sid');
ini_set('session.cookie_httponly', 1);
ini_set('session.cookie_secure', 1);
session_start();

References

Detected automatically by VulnRadar. The check id is php-version-exposed-in-cookie, stable across every scan so you can filter or diff on it.

See every info disclosure check

Questions

How severe is PHP session cookie naming exposes runtime?
VulnRadar rates this info severity in the info disclosure category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id php-version-exposed-in-cookie, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does PHP session cookie naming exposes runtime map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for php session cookie naming exposes runtime

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

PHP session cookie naming exposes runtime fix | VulnRadar