Session problem (var not registred)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • frimi

    Session problem (var not registred)

    Hi

    I've the following problem:

    Script 1 (sess2.php):
    <?php
    session_start() ;
    session_registe r('myReg');
    $myReg = "Hello";
    header("Locatio n: test.php",FALSE );
    exit();
    ?>

    Script 2 (test.php):

    <?php
    session_start() ;
    $mySessId = session_id();
    echo "SessId_Tes t = $mySessId <br>";
    $value = $_SESSION['myReg'];
    echo "myReg = $value <br>";
    ?>

    If i invoke sess2.php the first time (in a new browser) i receive the
    following result:

    SessId_Test = a729c9ae3dc91a0 b25b41ab4ab4922 16
    myReg =

    if i invoke sess2.php the second time (in the same browser) :

    SessId_Test = a729c9ae3dc91a0 b25b41ab4ab4922 16
    myReg = Hello

    Have someone an idea, why the session var is only the second time available?

    Regards, Michael



  • Robert Jirik

    #2
    Re: Session problem (var not registred)

    Wednesday 30 of July 2003 12:59, frimi wrote in comp.lang.php:
    [color=blue]
    > Script 1 (sess2.php):
    > <?php
    > session_start() ;
    > session_registe r('myReg');
    > $myReg = "Hello";
    > header("Locatio n: test.php",FALSE );
    > exit();
    > ?>[/color]

    You have it the other way round - first: $myReg = "hello" then
    session_registe r ...

    regards!

    -robert-


    --
    Robert Jirik
    [mailto:robert(a t)aristoteles(d ot)xhaven(dot)n et]
    public PGP key: http://xhaven.net/robert/pgp_key.asc
    -
    "Whenever you find yourself on the side of the majority,
    it's time to pause and reflect"
    -- Mark Twain

    Comment

    • frimi

      #3
      Re: Session problem (var not registred)

      Hi Robert

      I've changed the statement sequence => same effect (@#*%... ) !?

      Thanks, Michael


      "Robert Jirik" <robert@aristot eles.xhaven.net > schrieb im Newsbeitrag
      news:bg89o3$20a $1@news.nextra. cz...[color=blue]
      > Wednesday 30 of July 2003 12:59, frimi wrote in comp.lang.php:
      >[color=green]
      > > Script 1 (sess2.php):
      > > <?php
      > > session_start() ;
      > > session_registe r('myReg');
      > > $myReg = "Hello";
      > > header("Locatio n: test.php",FALSE );
      > > exit();
      > > ?>[/color]
      >
      > You have it the other way round - first: $myReg = "hello" then
      > session_registe r ...
      >
      > regards!
      >
      > -robert-
      >
      >
      > --
      > Robert Jirik
      > [mailto:robert(a t)aristoteles(d ot)xhaven(dot)n et]
      > public PGP key: http://xhaven.net/robert/pgp_key.asc
      > -
      > "Whenever you find yourself on the side of the majority,
      > it's time to pause and reflect"
      > -- Mark Twain
      >[/color]


      Comment

      Working...