Page 1 of 1

PHP Help

Posted: Fri Aug 08, 2003 8:18 am
by andrewt
Hi Guys,

I need some help. I am messing around with sessions variable.
This is the code.



<----START---->
<html>
<head>
<title></title>
<style></style>
</head>
<body>

<?
$a = session_start();
$_SESSION["tt"] = "aa";

echo $_SESSION["tt"] . "<br>";

$a = session_id();

echo $a;

$a = session_destroy();
/*
if (session_is_registered($_SESSION["sessSt"])) {
echo "Session Started";
}
else {
echo "Session not started";
$_SESSION["sessSt"] = 0;
}


*/

?>
</body>
</html>
<----END---->

And I've got this error.


Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html/test.php:4) in /var/www/html/test.php on line 9

Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/test.php:4) in /var/www/html/test.php on line 9
aa
d395371639205ece2f142c096a55611c



It seems that the script has implicitly register a session starting from <?
Can anyone please tell me whats going on here?

Thanks,
Andrew

Posted: Fri Aug 08, 2003 8:44 am
by Wayne
you need to put

Code: Select all

session_start();
before any other output including your html tags.

Move the session_start() to the first line of the script.

Wayne

Posted: Fri Aug 08, 2003 10:02 am
by andrewt
Thank you .... sooo much!!