Problem with Session Variables

Discussion in 'PHP' started by dwarfenhoschi, Mar 2, 2011.

  1. #1
    Hi there,

    I´m new here, I still hope someone can help me.

    I´ve got a little problem with PHP sessions. The thing is, I am initializing it right, it works just fine then, but after a little while, they seem to be disapearing...at least it looks like that. Heres an example:

    function end_page(){
        login_box();
        if(isset($_SESSION['user_id'])){
            menu_intern();
        }
    PHP:
    This part works just fine, it recognizes the user_id and when I try to output it it works.
    Right now I just try to output it in the menu_intern function, here:

    function menu_intern(){
        echo('<span class="menu_right"><div class="newshead">Intern Area</div><br />');
        echo($_SESSSION['user_id']);
        echo('</span>');
    }
    PHP:
    But it comes up empty. It happens with some other variable too at some point.
    I also keep getting the:

    error. From what I have found out, it should help to put the session_start() at the very beginning of the code (where it is now), which doesnt solve the error.

    I have not worked very much with sessions (at least it was a while back..), so I think I am missing something.

    If you´ve got any idea what might help with this I would appreciate it...thanks in advance !!

    greetings,
    dwarfenhoschi
     
    dwarfenhoschi, Mar 2, 2011 IP
  2. IAreOwn

    IAreOwn Active Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #2
    well. mostly this error means that there's an extra whitespace/blankspace at the beginning of <?php ... try to check, maybe the editor your using causes it.. i.e WSIWYG like MS Word.
     
    IAreOwn, Mar 2, 2011 IP
  3. dwarfenhoschi

    dwarfenhoschi Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nope...thats not it, double checked it.

    Could it be a problem that it is in an extra header file which i include with "require_once" ?


    *edit*Oh wow...that was stupid....noticed that in that function i wrote $_SESSSION ? Well I didnt...until now...
    And you were right, the header error was because of the uft bom stuff...just had no editor showing it, thanks !*/edit*
     
    Last edited: Mar 2, 2011
    dwarfenhoschi, Mar 2, 2011 IP