/    Sign up×
Community /Pin to ProfileBookmark

Session Error

Ok, i have managed to break my website doin nothing lol

i put in some more if statements nothing to do with session or anything and i get these errors

Warning: session_start(): Cannot send session cookie – headers already sent by (output started at /home/sites/apc-compunet.co.uk/public_html/functions/admin/common/admin_page_build.php:397) in /home/sites/apc-compunet.co.uk/public_html/functions/admin/login/login_auth.php on line 5

Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /home/sites/apc-compunet.co.uk/public_html/functions/admin/common/admin_page_build.php:397) in /home/sites/apc-compunet.co.uk/public_html/functions/admin/login/login_auth.php on line 5

Warning: Cannot modify header information – headers already sent by (output started at /home/sites/apc-compunet.co.uk/public_html/functions/admin/common/admin_page_build.php:397) in /home/sites/apc-compunet.co.uk/public_html/functions/admin/login/login_auth.php on line 63

i have taken all the code out i had put in before i had it working and the error still comes up

with these errors is there anything i should look for, there is far to much code to post it all up here

line 5 is session_start(); and line 63 is
header(“Location: ../../../admin/members/admin_members.php”);

i really dont know what i have done as i wasn’t touching anything to do with sessions.

im pullin my hair out over this so anyhelp will be great. i get the same error on everypage that has a session_start(); in if its any help

Thanks Adam

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 18.2004 — I believe you are getting these errors because you have something in your script/page which is generating output before those commands are executed. Any "echo", "print", or any function that writes ouput to your browser (regardless of whether it is displayable) will cause those errors, as well as any "naked" html outside of your "<?php" "?>" script delimiters.
Copy linkTweet thisAlerts:
@solavarAug 18.2004 — Here is what you might have done wrong:

[code=php]

<?php
//the wrong way

include("somefile.php");

session_start();

// etc...

[/code]


This is very risky and usually results in the sort of errors you have.

  • 1. session_start() must be the VERY FIRST line.


  • 2. The file, 'somefile.php' has some stuff in it which is sending output to the browser. And then you are calling session_start() later.


  • So, simply make sure session_start() comes before ANYTHING ELSE!

    [code=php]

    <?php
    //the right way

    session_start();

    include("somefile.php");



    // etc...

    [/code]
    Copy linkTweet thisAlerts:
    @k0r54authorAug 18.2004 — sorry i have looked for everything you have said and nothing, is there, anything else i can try i did have it the wrong way around but i have changed it now

    i really dont know where to begin with the code there is so much and i dont know wat im havin problems with its just the lines of code you see obove like the header(Location: blah blah );

    just stuff like that and my session are all screwed

    thanks adam
    Copy linkTweet thisAlerts:
    @k0r54authorAug 18.2004 — ok the session are fine, since changing them to after the required files its not bringing up any errors like that

    its now just the line 63

    header("Location: ../../../admin/members/admin_members.php");

    this seams to be for every redirect :s
    Copy linkTweet thisAlerts:
    @k0r54authorAug 18.2004 — by the way this bit in the error here

    (output started at /home/sites/apc-compunet.co.uk/public_html/functions/admin/common/admin_page_build.php:646)

    line 646 of that page is the end of the document :S its ?> and only that
    Copy linkTweet thisAlerts:
    @NogDogAug 18.2004 — [i]Originally posted by k0r54 [/i]

    [B]ok the session are fine, since changing them to after the required files its not bringing up any errors like that



    its now just the line 63



    header("Location: ../../../admin/members/admin_members.php");



    this seams to be for every redirect :s [/B]
    [/QUOTE]

    It's almost certainly what I stated above: something in lines 1-62 is generating output. Both of these will fail the same way:
    [code=php]<html>
    <?php
    if($some_condition) {
    header("Location: ../../../admin/members/admin_members.php");
    }
    # rest of page
    ?>
    </html>[/code]

    [code=php]<?php
    echo "<html>";
    if($some_condition) {
    header("Location: ../../../admin/members/admin_members.php");
    }
    # rest of page
    echo "</html>";
    ?>[/code]

    Correct (no output of any kind preceding header():
    [code=php]<?php
    if($some_condition) {
    header("Location: ../../../admin/members/admin_members.php");
    }
    echo "<html>";
    # rest of page
    echo "</html>";
    ?>[/code]
    Copy linkTweet thisAlerts:
    @solavarAug 18.2004 — Yes, you can not use:

    header("location: etc, etc")

    after headers have already been sent.

    This is a bit of stumbling block, all the time.

    I use a workaround, like this...

    [code=php]

    //instead of this
    header("Location: ../../../admin/members/admin_members.php");

    // try
    echo '<meta http-equiv="refresh" content="0; url=../../../admin/members/admin_members.php">';
    exit;

    //NOTE: you may need to use the full path to get it to work.


    [/code]
    Copy linkTweet thisAlerts:
    @k0r54authorAug 18.2004 — OK! its suddenly started working now and i havn't changed anything only the session_start bit but it didn't work when i tried it first

    why is it so inconsistent ?
    Copy linkTweet thisAlerts:
    @NogDogAug 18.2004 — [i]Originally posted by k0r54 [/i]

    [B]OK! its suddenly started working now and i havn't changed anything only the session_start bit but it didn't work when i tried it first



    why is it so inconsistent ? [/B]
    [/QUOTE]

    Gotta be the Internet Gremlins at work again. ?
    ×

    Success!

    Help @k0r54 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.21,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...