Quantcast
Viewing all articles
Browse latest Browse all 291721

[PHP 7.2] "session_id(): Cannot change session id"

On PHP 7.2, these warning show up in the logs at admin/reports/dblog:

  • Warning: session_id(): Cannot change session id when headers already sent in drupal_session_initialize() (line 266 of includes/session.inc).
  • Warning: session_set_save_handler(): Cannot change save handler when headers already sent in drupal_session_initialize() (line 242 of includes/session.inc).

Steps to reproduce:

  1. Enable page cache;
  2. Enable statistics module;
  3. Enable access log at admin/config/system/statistics;
  4. As anonymous user load a cached page which is longer than PHP output buffer, or of any length if PHP output_buffering is disabled

In this case, statistics_exit() is initializing session after the page has already been sent.

The proposed patch at #48 no longer attempts to initialize a session in statistics_exit(). Requests being served from the page cache will have empty string stored in the sid column of the accesslog table, which is what session_id() returns when there is no session.


Viewing all articles
Browse latest Browse all 291721

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>