470,833 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

$_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_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.
Jul 17 '05 #1
1 2007
On Thu, 29 Jan 2004 17:36:42 -0500, "toufik toufik" <to*****@sympatico.ca>
wrote:
session_start();
session_register("myVar");
$_SESSION['myVar'] = 'test';
login1.php :
=======
session_start();
echo ($_SESSION["myVar"]);


http://www.php.net/session_register

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

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Rob Tweed | last post: by
reply views Thread by Phil Powell | last post: by
3 posts views Thread by Phil Powell | last post: by
15 posts views Thread by mammothman42 | last post: by
2 posts views Thread by Tom | last post: by
12 posts views Thread by Michael Windsor | last post: by
14 posts views Thread by Sandman | last post: by
4 posts views Thread by Pseudonyme | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.