You are here: Confusing session behaviour « PHP Programming Language « IT news, forums, messages
Confusing session behaviour

Posted by David Haynes on 02/25/06 21:38

I am running Apache 2, PHP 5.0.5, and windows XP

I have one php file that populates a SESSION variable and another that
consumes it.

If I call the first one from the URL line of the browser, the form fills
correctly (i.e. the values are passed in the session)

If I call the first program from the second via an <a href> the session
is lost.

So, from the browser URL, the order would be:
[first.php]
session_start();
$_SESSION['foo'] = $foo;
session_write_close();
header("location: second.php");
exit;

[second.php]
session_start();
$foo = $_SESSION['foo'];
print_r($foo);

This works.

If I change second.php to be:
session_start();
$foo = $_SESSION['foo'];
<a href="first.php">first</a>

then the session is empty when the href is selected.

What am I missing?
-david-

 

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

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