Support » Plugin: WordPress Native PHP Sessions » Cannot send session cookie – headers already sent

  • Resolved ThermalStudios

    (@thermalstudios)


    I am a pantheon wordpress user. I have deactivated all of my plugins except for Akismet and reinstalled the plugin. Pagecache is disabled. When I add session_start(); to a page template I get this…

    Warning: session_start(): Cannot send session cookie – headers already sent by (output started at /srv/bindings/1fcf4f5101594f719ff351d54bc222aa/code/wp-content/themes/thermal/inc/nav-inc.php:6) in /srv/bindings/1fcf4f5101594f719ff351d54bc222aa/code/wp-content/themes/thermal/page-promo.php on line 55 utid=

    Any ideas?

    UPDATE: This error is due to session_start() being called from elsewhere in the wordpress core. Session tracking is still not functioning though. Should I be able be able to work with session variables if I just leave out session_start()?

    Here is a basic test I am running. I want to get the utid param form the url if it exists, otherwise pull it from the session param…

    if (!empty($_GET[‘utid’])) {
    $_SESSION[“utid”] = $_GET[‘utid’];
    }
    echo “utid=”. $_SESSION[“utid”];

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ThermalStudios

    (@thermalstudios)

    I have been through all the session-related docs on pantheon’s website and tried everything. I moved the plugin to the mu-plugins folder and then realized wordpress treats it like 2 plugins (pantheon-sessions.php and callbacks.php). So I left pantheon-sessions.php alone and moved the other files into a folder (/wp-native-php-sessions). Then I updated all the file references inside pantheon-sessions.php to point to this folder. It seems I’m back to square one now. WordPress recognized the mu plugin but it doesn’t store session data.

    I still get the “headers already sent” error if use session_start().

    When I remove session_start() I can add ?utid=123 to the url and the code listed above will return the params when I echo them on the page but as soon as I move to a new page the session data is lost. I have spent many hours on this. Please help!

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    I still get the “headers already sent” error if use session_start().

    Can you make sure your use of session_start() is above the call to get_header();, not below?

    Thread Starter ThermalStudios

    (@thermalstudios)

    Uugh! it was so simple. Thank you, thank you Daniel. Resolved.

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Glad you got it sorted out! Sorry I didn’t reply earlier — it was on my list of things to do.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cannot send session cookie – headers already sent’ is closed to new replies.