Problem in session valiable when accessing

Discussion in 'PHP' started by kks_krishna, May 15, 2007.

  1. #1
    HI,

    I am not able to access the session variable $user_name = $_SESSION['USER_NAME']; when accessing inside a included page. I have included one page using include() function. the session variable is not available inside that. the following is the code i used for registering session:

    session_start();
    session_register('USER_NAME');
    $_SESSION['USER_NAME'] = $user_name;
     
    kks_krishna, May 15, 2007 IP
  2. missenlinx

    missenlinx Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you including the include page after the session start if so then there should be no problem at all.
     
    missenlinx, May 15, 2007 IP
  3. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #3
    yes, but its not working.
     
    kks_krishna, May 15, 2007 IP
  4. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #4
    if you use session_register don't use $_SESSION to register your variable again. use one or another, but not both!!

    better is to use $_SESSION['var'] = $value;
     
    gibex, May 16, 2007 IP
  5. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #5
    from php manual:

     
    gibex, May 16, 2007 IP