|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80774 session_name() problem with backslash
Submitted: 2021-02-19 09:04 UTC Modified: 2021-02-19 11:13 UTC
From: chirpinternet at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Session related
PHP Version: 7.3.27 OS: Debian
Private report: No CVE-ID: None
 [2021-02-19 09:04 UTC] chirpinternet at gmail dot com
We have a trait for handling sessions, which includes (abbreviated):

trait SessionOpenCloseTrait {

  protected function open_session($name) {


Other classes invoke this using __CLASS__ as the $name parameter:

class SecureToken {

  use SessionOpenCloseTrait;

  public function __construct()   {


When namespaced, __CLASS__ contains a backslash (e.g. "Parent\SecureToken").  This has not been a problem until a security upgrade took us from 7.3.19 to 7.3.27.  After the upgrade the SESSION was being written to the server as normal, but no longer accessible on subsequent requests.  *Possibly* due to encoding of the cookie name.

To fix this, we had to remove the '\':

  protected function open_session($name) {
+   $name = str_replace("\\", "", $name);


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-19 11:13 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-02-19 11:13 UTC]
Thanks for reporting!

This regression has been introduced by the fix for bug #79699,
because cookie names are no longer URL decoded, but session_name()
still URL encodes the session name.

Note that PHP 7.3 is out of active support, so this will not be
fixed for that version.
 [2021-02-19 12:25 UTC]
The following pull request has been associated:

Patch Name: Fix #80774: session_name() problem with backslash
On GitHub:
 [2021-02-22 11:38 UTC]
Automatic comment on behalf of
Log: Fix #80774: session_name() problem with backslash
 [2021-02-22 11:38 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 22 21:01:28 2024 UTC