Hi,
I am trying to get $_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access $_SESSION on both pages.
Page 1
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
$_SESSION['item1'] = "First session variable";
echo $_SESSION['item1'];
echo '<br /> <a href="session2. php"> click here </a>';
?>
</body>
</html>
[/PHP]
This displays the $_SESSION['item1'] correctly and the link takes you to the second page.
Page 2
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
echo 'My first variable: ' . $_SESSION['item1'];
?>
</body>
</html>
[/PHP]
This however, only displays the basic text and nothing comes out from the $_SESSION['item1'].
I am really ew to this idea and I need to understand this is order to get the site I am developing to be properly interactive.
Can anybody see what am missing with this simple example?
Cheers
nathj
I am trying to get $_SESSION to work on my site. In order to learn this an dunderstand it better I have built two very simple test pages to see if i can access $_SESSION on both pages.
Page 1
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
$_SESSION['item1'] = "First session variable";
echo $_SESSION['item1'];
echo '<br /> <a href="session2. php"> click here </a>';
?>
</body>
</html>
[/PHP]
This displays the $_SESSION['item1'] correctly and the link takes you to the second page.
Page 2
[PHP]
<?php /* Created on: 03/07/2007 */
session_start() ;?>
<html>
<body>
<?php
echo 'My first variable: ' . $_SESSION['item1'];
?>
</body>
</html>
[/PHP]
This however, only displays the basic text and nothing comes out from the $_SESSION['item1'].
I am really ew to this idea and I need to understand this is order to get the site I am developing to be properly interactive.
Can anybody see what am missing with this simple example?
Cheers
nathj
Comment