sessions: here I come!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Brakanjan
Forum Newbie
Posts: 19
Joined: Wed May 14, 2003 9:57 am
Location: South Africa

sessions: here I come!

Post 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
Black Unicorn
Forum Commoner
Posts: 48
Joined: Mon Jun 16, 2003 9:19 am
Location: United Kingdom

Post 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"]}");
}
Brakanjan
Forum Newbie
Posts: 19
Joined: Wed May 14, 2003 9:57 am
Location: South Africa

Post 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?
Post Reply