Posted by helloroger on 02/26/06 20:20
Hi folks
I'm new to php an currently trying to insall my first php-Session. I've
written the following code which uses the 2 variables cat and langua,
but somehow they are not correctly registered in the session. When
pressing the links to set the 2 session variables, they don't move at
all. There values are always 1 and 9.
Does anybody have an idea how I can set the value of a session variable
using a <a href ...>?
Any help appreciated.
Sunnyboy
<?php
session_start();
session_register("cat");
session_register("langua");
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<?php
echo "langua = $langua<br>";
echo "cat = $cat<br>";
// Read variable langua
if (!isset ($_SESSION["langua"]))
{
echo "langua not registerd in session<br>";
$langua = 1;
}
else
{
echo "langua registerd in session<br>";
$langua = ($_SESSION['langua']);
}
// Read variable cat
if (!isset ($_SESSION["cat"]))
{
echo "cat not registerd in session<br>";
$cat = 9;
}
else
{
echo "cat registerd in session<br>";
$cat = ($_SESSION["cat"]);
}
echo "langua = $langua<br>";
echo "cat = $cat<br>";
?>
<br><br>
<a href="?langua=2">set langua=2</a><br>
<a href="?langua=3">set langua=3</a>
<br><br>
<a href="?cat=3">set cat=3</a><br>
<a href="?cat=4">set cat=4</a>
<br><br>
<?php
echo "cat=$cat<br>";
echo "langua=$langua<br>";
session_write_close();
?>
</BODY>
</HTML>
Navigation:
[Reply to this message]
|