session_start and HTTP headers in Mozilla, plz help
| From: | Lars Olsson | Date: | Thu, 11 Jul 2002 12:16:44 +0000 |
| Subject: | session_start and HTTP headers in Mozilla, plz help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-107108@lists.php.net to get a copy of this message | ||
Hi!
I've run across a problem when using session_start and HTTP headers in Mozilla. I'm trying to write a snippet of code that checks whether a user has logged in or not. If the user has a session variable set I want to display the page and if he or she hasn't I want to give them a 403 Forbidden header. My current code looks like this:
[top of page]
<?php
// Start session handling
session_start();
// Check login
if (isset($HTTP_SESSION_VARS["xyz"])
and $HTTP_SESSION_VARS["xyz"] == "yes") {
?>
<html>
[page contents]
</html>
<?php
}
else {
header("HTTP/1.0 403 Forbidden");
}
?>
[end of page]
This works perfectly in IE 6 (I get a 403 Error Message) but in Mozilla I just get an empty page (containing just the <html> and <head> tags). Most other headers seem to work though.
If I use header("Location: somepage.php") both Mozilla and IE correctly
redirects the browser. I don't know if it's a bug in IE or Mozilla or if I'm plain stupid, but perhaps someone else has experienced this and are willing to give me a hint?
Thanks
/lasso