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
- 1Override the default session cookie name in php.ini: session.name = sid
- 2Alternatively, set it at runtime before session_start(): ini_set('session.name', 'sid');
- 3Choose a name that does not reference the framework or language.
- 4Also set session.cookie_httponly = 1 and session.cookie_secure = 1 in php.ini.
Code examples
PHP (php.ini)
; Rename the session cookie to a generic opaque name
session.name = sid
session.cookie_httponly = 1
session.cookie_secure = 1
session.cookie_samesite = StrictPHP (runtime, before session_start)
// 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.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
- InforeCAPTCHA site key exposure
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.