Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    14

    Unanswered: variable cant be accessed

    i have a problem! i am trying to use session variable.i am simply trying to access a session variable stored in one page from next page

    i wrote a program..the code goes like this.

    <?php
    session_start();
    $save_this=19;
    $_SESSION['save_this']=$save_this;
    if($_SESSION['save_this']=="19")
    {
    header("location:two.php");
    }
    ?>

    and in the two.php page, the code is like this

    <?php
    session_start();
    $saved_previous=$_SESSION['save_this'];
    echo ($saved_previous);
    ?>

    but when i run it..in first time it always shows error
    Notice: Undefined index: save_this in two.php on line 4

    however when i run the page second time in the same explorer window it works fine...that is it displays 19...i dont know what is going wrong!!
    please help me!!!!

  2. #2
    Join Date
    Nov 2004
    Posts
    1
    I always have after...
    {
    header("Location:...");
    exit();
    }

    Not sure if that is your solution or not.

  3. #3
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Thumbs up Use Session_register()

    Use session_register() function to register your session variable..I think that is the problem...

    Hope this helps..Do let me know whether this solved ur problem
    Sudar

    --
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •