Page 1 of 1

sessions: here I come!

Posted: Tue Jul 08, 2003 1:53 am
by Brakanjan
Hi

I am figuring sessions (and php :) ), but already something doesn't work. my one file ses1.phtml is:

<?php
session_start();
$_SESSION['name'] = 'TheName';
echo '<a href="ses2.phtml">GOTO</a>';
?>

and ses2.phtml is:

<?php
session_start();
echo $_SESSION['name'];
?>

why don't I get an output in ses2.phtml?

tx

Posted: Tue Jul 08, 2003 3:41 am
by Black Unicorn
Perhaps you should try, also:

session_register("TheName");

before assigning a value to it. For instance,

session_start();
if (!IsSet($_SESSION["name"])){
session_register("name");
$name = "Moby";
header("Location:{$_SERVER["PHP_SELF"]}");
}

Posted: Tue Jul 08, 2003 4:41 am
by Brakanjan
nope, there's another problem.

my code works fine when I run it on my ISP over the internet, but on my own php server (localhost) is doesn't seem to work. I must probably set session somewhere, but everything seems fine in the php.ini file. any clues?