Hi, i've probs in setting cookies n sessions. When i set them on one pg, it somehow doesn't appear on other pgs i.e. e variables r empty. But thr doesn't seem to b anything wrong wif e code cos previously, it was working on another host. Can any1 pls help me? Thank you!

TESTCOOKIE1.php
<?php
if(!session_start())
session_start();

$name="he";
setcookie("uname", $name, time()+36000);
setcookie("PHPSESSID",session_id(),time()+3600);

session_register ("test_S");
$HTTP_SESSION_VARS ["test_S"] = "testvalue";
?>
<html>
<body>
<a href="testcookie2.php">next pg</a>
</body>
</html>







TESTCOOKIE2.PHP
<?php
if(!session_start())
session_start();

echo ("$test_S");

if (isset($_COOKIE["uname"]))
echo "Welcome " . $_COOKIE["uname"] . "!<br />";
else
echo "You are not logged in!<br />";

if (isset($_COOKIE["PHPSESSID"]))
echo "Welcome " . $_COOKIE["PHPSESSID"] . "!<br />";
else
echo "You are not logged in!<br />";
?>
<html>
<body>
</body>
</html>

 

 

 


Reply