$_SESSION question

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

    $_SESSION question

    Hi,
    I've a file login.php that create a session, register a variable(myVar) and
    call (include) another file login1.php in the server side.
    I need to use the registred variable in the second file but
    $_SESSION["myVar"] is empty.

    here is a simplified example of my problem, the command echo
    ($_SESSION["myVar"]) isn't displaying any thing
    login.php :
    ========
    <?php
    $myVar="test"
    session_start() ;
    session_registe r("myVar");

    include("login1 .php");
    ?>

    login1.php :
    =======
    <?php
    session_start() ;

    echo ($_SESSION["myVar"]);
    ?>

    Note: I need to have myVar in the $_SESSION array in login1.php because in
    other context I call it from the browser, so I'll the same code.
    Thanks.


  • Andy Hassall

    #2
    Re: $_SESSION question

    On Thu, 29 Jan 2004 17:36:42 -0500, "toufik toufik" <toufiki@sympat ico.ca>
    wrote:
    [color=blue]
    > session_start() ;
    > session_registe r("myVar");[/color]

    $_SESSION['myVar'] = 'test';
    [color=blue]
    >login1.php :
    >=======
    > session_start() ;
    > echo ($_SESSION["myVar"]);[/color]

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    Read manual, see third big "Caution" note, stop using session_registe r() ;-p

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

    Comment

    Working...