For some reason I can't put any html before my session_start function. There is no white space, text or echo statements before this function so I don't know why it is a problem. I should be able to output html and then use my session_start() shouldn't I?
Normally you just use html and then use your <?php tag as normal, but here it isn't working, what am I doing wrong?
Here's my code.
<html>
<head></head>
<body>
<?php
session_start();
if(!isset($_SESSION['userID']))
{
echo "You are not logged in properly or you have already logged out, you need to visit our <a href = \"loginform.html\">Login page</a> to log in again.";
exit();
}
else
{
unset($_SESSION['username']);
unset($_SESSION['userID']);
echo "Successfully logged out. If you've just made a mistake and need to log back in again, you'll need to visit our <a href = \"loginform.html\">login page</a>.";
}
exit();
?>
</body>
</html>
I'm getting these errors:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Webpages\icp\logout.php:5) in C:\Webpages\icp\logout.php on line 6
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Webpages\icp\logout.php:5) in C:\Webpages\icp\logout.php on line 6
You are not logged in properly or you have already logged out, you need to visit our Login page to log in again.