Welcome Guest, Not a member yet? Register   Sign In
Session and headers sent problems :(
#1

[eluser]chobo[/eluser]
I'm trying to get my new version of my site to work, but I'm running into problems with headers and session. This probably has something to do with me being on a shared host because I never have these problems on my test computer.

I made my own session wrapper library, it's very simple and when I run the init() function to start the session, it triggers the "headers already sen" error. I'm not sure how to get my session to run before the server sends it's headers. Any help is appreciated, thanks

Code:
/*
    *    Check if session has been started and if header have been sent
    */
    private function init()
    {
        if (! isset($_SESSION))
        {
            if (headers_sent())
            {
                trigger_error ('Session was not started before headers sent');
            }
            else
            {
                session_start();
            }
        }
    }
#2

[eluser]Michael Wales[/eluser]
Make sure there isn't any whitespace being sent prior to the session_start() function (spaces at the top/bottom of files that are previously loaded).
#3

[eluser]chobo[/eluser]
I actually ran into that header problem as well, thanks Whales Smile. Well it took about three and a half hours to get it all working, but it's finally up and running in Codeigniter Smile For the session problem I fixed it by placing ob_start() at the top of all my front controller files (I have two), and an ob_end_flush() at the end. God, what a nightmare and this was with a couple of hours of prep on top of it...
#4

[eluser]birkof[/eluser]
Same problem here, solved in chobo's way. Thanks




Theme © iAndrew 2016 - Forum software by © MyBB