By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Session problem (var not registred)

P: n/a
Hi

I've the following problem:

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

Script 2 (test.php):

<?php
session_start();
$mySessId = session_id();
echo "SessId_Test = $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 = a729c9ae3dc91a0b25b41ab4ab492216
myReg =

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

SessId_Test = a729c9ae3dc91a0b25b41ab4ab492216
myReg = Hello

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

Regards, Michael

Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Wednesday 30 of July 2003 12:59, frimi wrote in comp.lang.php:
Script 1 (sess2.php):
<?php
session_start();
session_register('myReg');
$myReg = "Hello";
header("Location: test.php",FALSE);
exit();
?>


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

regards!

-robert-
--
Robert Jirik
[mailto:robert(at)aristoteles(dot)xhaven(dot)net]
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

Jul 16 '05 #2

P: n/a
Hi Robert

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

Thanks, Michael
"Robert Jirik" <ro****@aristoteles.xhaven.net> schrieb im Newsbeitrag
news:bg**********@news.nextra.cz...
Wednesday 30 of July 2003 12:59, frimi wrote in comp.lang.php:
Script 1 (sess2.php):
<?php
session_start();
session_register('myReg');
$myReg = "Hello";
header("Location: test.php",FALSE);
exit();
?>


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

regards!

-robert-
--
Robert Jirik
[mailto:robert(at)aristoteles(dot)xhaven(dot)net]
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

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.