How to pass a same variable across mutiple pages using sessions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemashiki
    New Member
    • Aug 2006
    • 34

    How to pass a same variable across mutiple pages using sessions

    hi
    i cant pass a same variable to multiplepages.. .
    while passing variables in sessions
    it shows warning and it doesn't pass to multiple pages
    here the coding which i hve used
    Registration.ph p
    <?
    session_start() ;
    session_registe r("username") ;
    $username=$_POS T['t3'];
    ?>
    Registration1.p hp
    <?
    session_start() ;
    echo "".$usernam e;
    ?>
    update.php
    <?
    session_start() ;
    echo "".$usernam e;
    $q1="UPDATE `realtour` SET list='$protype' where uname='$usernam e'";
    ?>

    in the above....
    i cant get the value of username where used in Registration1.p hp
    can anyone suggest me
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Passing variables can best be done via the $_SESSION array.
    Originally posted by php doc
    If your script uses session_registe r(), it will not work in environments where the PHP directive register_global s is disabled.
    So in your case it is best to code as follows:
    [php]Registration.ph p:
    ------------------
    <?php
    session_start() ;
    $username=$_POS T['t3'];
    $_SESSION['username'] = $username;

    Registration1.p hp:
    ------------------
    <?php
    session_start() ;
    echo $_SESSION['username'];

    update.php:
    -----------
    <?php
    session_start() ;
    $username = $_SESSION['username'];
    echo $username;
    [/php]

    Ronald :cool:

    Comment

    • hemashiki
      New Member
      • Aug 2006
      • 34

      #3
      Hi
      thanks for ur suggestion
      its working well

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        You are most welcome.

        Ronald :cool:

        Comment

        Working...