session is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridharmca
    New Member
    • Mar 2007
    • 2

    session is not working

    I am developing a web site for forum. In login page. I registered the username as person in the session. And I try to read that person into another page. I will not working. I gave session_start() and session_registe r('person') functions in the home page.
    the isset will return false.
    sample coding
    // in login.php
    $_SESSION['person']=$userid;
    // forumlist.php
    echo $_SESSION['person'];
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    If you did what you said you did, it should work okay. But are you definitely sure that the $userid variable contains any value?? To be certain, check again.
    BOTH pages must start with the session_start! Like this

    LOGIN.PHP
    [php]
    <?php
    session_start() ;
    if (isset($userid) AND $userid > ' ')
    $_SESSION['person']=$userid;
    else
    die ("Userid variable not set");
    .... etc code ....
    [/php]
    FORUMLIST.PHP
    [php]
    <?php
    session_start() ;
    echo $_SESSION['person'];
    .... etc code ...
    [/php]

    Ronald :cool:

    Comment

    Working...