Serious problem with sessions
Posted: Mon May 05, 2003 2:27 pm
I've read "Before Post Read: Sessions with a Minor in User Logins" and I've tried the example there on my computer. But something is seriously wrong anyway..
on page1.php the session works fine.. but when I move on to page2.php and so on the session is lost.
I have ver 4.3.1 of PHP so I have to use the superglobals but they won't work for me.
Anyone who knows what the problem might be?
The code for these two pages is:
--- page1.php ---
The first page prints:
$_SESSION[username] equals jason
Go to page 2
--- page2.php ----
The second page prints:
$_SESSION[username] equals
Go to page 3
on page1.php the session works fine.. but when I move on to page2.php and so on the session is lost.
I have ver 4.3.1 of PHP so I have to use the superglobals but they won't work for me.
Anyone who knows what the problem might be?
The code for these two pages is:
--- page1.php ---
Code: Select all
<?php
session_start();
if ( !isset($_SESSIONї'username']) ) {
$_SESSIONї'username'] = 'jason';
}
echo '$_SESSIONїusername] equals '.$_SESSIONї'username']; echo '<br><br><a href="page2.php">Go to page 2</a>';
?>$_SESSION[username] equals jason
Go to page 2
--- page2.php ----
Code: Select all
<?php
session_start();
echo '$_SESSIONїusername] equals '.$_SESSIONї'username']; // This doesn't work!!
echo '<br><br><a href="page3.php">Go to page 3</a>';
?>$_SESSION[username] equals
Go to page 3