$_SESSION question

From: toufik toufik (toufiki_at_sympatico.ca)
Date: 01/29/04


Date: Thu, 29 Jan 2004 17:36:42 -0500

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_register("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.



Relevant Pages

  • Re: Session variables are lost, disappear from page to page
    ... MS Windows Server 2003 ... says 'edit records' and 'delete records'. ... the data in the session array is gone. ... I think it's a PHP bug, but PHP support won't acknowledge it as a bug, ...
    (comp.lang.php)
  • Re: Session variables are lost, disappear from page to page
    ... MS Windows Server 2003 ... says 'edit records' and 'delete records'. ... the data in the session array is gone. ... I think it's a PHP bug, but PHP support won't acknowledge it as a bug, ...
    (comp.lang.php)
  • Re: Simultaneous calling two PHP scripts
    ... After data received, the JavaScript ... If I have one XHR in 'wait' state (so the PHP ... subsequent communication with the server. ... you should call session_write_close() before waiting to free up the session for another request. ...
    (comp.lang.php)
  • Re: PHP/Apache or IE problem (no GPC data)
    ... not really about PHP but this is the best ... we get complaints from our customers about them losing their session. ... 20 times per 200k hits (one day's work per server). ... Still I saw http hits without any get/post/cookie data, ...
    (comp.lang.php)
  • Re: carrying over variables from a form to multiple pages...
    ... have to register each one of these manually with $_SESSION. ... JDS Computer Training Corp. ... But you don't have to register variables in the session. ...
    (comp.lang.php)