I've got a problem getting sessions to work and I wondered if anyone could
offer any advice.

The example I am using is to get one page to set variables in a session and
then use another page to retrieve them.  I am using 4.3.4RC2 and prior to
that 4.3..3 on Win2k with IE6 and Apache 1.3.22.

The code is:

page1.php
----------
<?php
 session_start();

 $_SESSION['foo'] = 'Hello';
 $_SESSION['bar'] = 'World';

 ?>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>

Variables set in session - hopefully???

<?php
 echo "foo = {$_SESSION['foo']}<BR>";
 echo "bar = {$_SESSION['bar']}";
?>

<form action="page2.php" method="post">
<input type="submit" name="submit" value="Page 2" />
</form>

</BODY>
</HTML>

page2.php
----------
<?php
 session_start();
 echo "foo = {$_SESSION['foo']}";
 echo "bar = {$_SESSION['bar']}";

?>

On page 1 I am seeing the session variables displayed correctly i.e. Hello
World and I can see a session file created in my temp directory with the
correct values in there.  However, when I display page 2 the variables are
always displayed blank and what seems to happen is that a new empty session
file is created in my temp directory.  It's as though the second page is not
related to the same session somehow.  I've also tried lots of other examples
from books and on the net and I still can't get sessions to work.

Am I doing something wrong in connecting the two pages although I don't
close the browser down at all between the two?

Any ideas would be greatly appreciated.

Thanks

Shaun Campbell



-- 
Shaun Campbell
IT Consultant
apps2net

Tel: 07900 911072
Email: [EMAIL PROTECTED]
Web: www.apps2net.co.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to