Help with session vars

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Northrop
    New Member
    • Jan 2007
    • 67

    Help with session vars

    I have on one page:
    session_start() ;
    session_registe r ("email");
    session_registe r ("firstname" );
    session_registe r ("lastname") ;
    $HTTP_SESSION_V ARS ["email"] = $email;
    $HTTP_SESSION_V ARS ["firstname"] = $firstname;
    $HTTP_SESSION_V ARS ["lastname"] = $lastname;

    when i type:
    echo $HTTP_SESSION_V ARS ["email"] ;
    on this page it displays the users email taken from a form.

    I then added a link to another page with a form

    when i submit the form it goes to a php script which has
    echo $HTTP_SESSION_V ARS ["email"] ;
    This has no result.

    Am i doing something wrong?
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Originally posted by Shawn Northrop
    I have on one page:
    session_start() ;
    session_registe r ("email");
    session_registe r ("firstname" );
    session_registe r ("lastname") ;
    $HTTP_SESSION_V ARS ["email"] = $email;
    $HTTP_SESSION_V ARS ["firstname"] = $firstname;
    $HTTP_SESSION_V ARS ["lastname"] = $lastname;

    when i type:
    echo $HTTP_SESSION_V ARS ["email"] ;
    on this page it displays the users email taken from a form.

    I then added a link to another page with a form

    when i submit the form it goes to a php script which has
    echo $HTTP_SESSION_V ARS ["email"] ;
    This has no result.

    Am i doing something wrong?
    Start the session on the second page before you call for the session variable.
    [PHP]
    <?php
    session_start() ;
    echo $HTTP_SESSION_V ARS ["email"] ;
    ?>
    [/PHP]

    Comment

    • Shawn Northrop
      New Member
      • Jan 2007
      • 67

      #3
      Originally posted by ajaxrand
      Start the session on the second page before you call for the session variable.
      [PHP]
      <?php
      session_start() ;
      echo $HTTP_SESSION_V ARS ["email"] ;
      ?>
      [/PHP]
      Thanks that worked. Do i want to call session_close() ; on every page or only when the user logs out?

      Comment

      • exoskeleton
        New Member
        • Sep 2006
        • 104

        #4
        only when you log out! but what do you want to do...to close the session or destroy it? :)

        not just session_destroy () ... you have to clear all the arrays ... many previous topic about clearing the sessions...try to search in this site...i asked about this few months ago...hehe... :)

        more power good sir

        Comment

        Working...