Cannot send session cache limiter - headers already sent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gipsy
    New Member
    • Dec 2007
    • 1

    Cannot send session cache limiter - headers already sent

    Hello,

    I know that you guys are familiar with this, but I tried almost every solution I googled, but no chance getting it wroked, here is the error.


    Warning: session_start() [function.sessio n-start]: Cannot send session cookie - headers already sent by (output started at /home/admin/public_html/xxx/xxx/userclass.php:6 2) in /home/admin/public_html/xxx/xxx/sessiondata.php on line 28

    Warning: session_start() [function.sessio n-start]: Cannot send session cache limiter - headers already sent (output started at /home/admin/public_html/xxx/xxx/userclass.php:6 2) in /home/admin/public_html/xxx/xxx/sessiondata.php on line 28

    and here is the sessiondata.php lines, that have the error.
    [code=php]
    if ($sessionFileDi r != "") {
    session_save_pa th($sessionFile Dir);
    }

    if ($SID == "") {
    session_start() ;
    $SID = session_id();
    } else {
    session_start($ SID);
    }
    [/code]

    Hope I can get any help soon.
    Last edited by Atli; Dec 9 '07, 02:23 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi. Welcome to TSDN!

    You get this error when you try to start a session after something has been printed (or echoed) to the response.

    The session_start function must be called first, before anything is added to the response. Once you start adding to the response the headers are locked, and the session can not be started.

    If you can in no way modify your design so the session_start function gets called first, then check out the Output Control functions.

    Comment

    Working...