You are here: Why does a session variable return to its old value? « PHP Programming Language « IT news, forums, messages
Why does a session variable return to its old value?

Posted by damezumari on 06/13/07 13:09

I have a problem in my application I have not been able to reproduce
completely with a simpler set of files. I know this is a crime, but
here goes:

In a file I have these instructions:

echo 'before: '.$_SESSION['classtitle'].'<br />';
require_once 'test3.php';
echo 'after: '.$_SESSION['classtitle'].'<br />';
echo '<p><a href="test.php">test</a></p>';

They display on the screen:

before: b
test3 before: b
test3 after: a
after: a

So far, so good. But, when I click the link to test.php, this is
displayed:

test: b

I don't understand how $_SESSION['classtitle'] goes back to its old
value.

Here are test3.php and test.php:

test3.php:
<?php
session_start();
echo 'test3 before: '.$_SESSION['classtitle'].'<br />';
$_SESSION['classtitle'] = 'a';
echo 'test3 after: '.$_SESSION['classtitle'].'<br />';
?>

<?php
session_start();
echo 'test: '.$_SESSION['classtitle'].'<br />';
?>

Can anyone point me in the right direction, please?

Regards,

Jan Nordgreen

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация