fuse3k Posted July 10, 2006 Share Posted July 10, 2006 Could someone tell me why the statement is completely being ignored when the conditional is TRUE? It just continues to load the page as usual. Using OB, nothing sent to browser prior. If I change header() to redirect to another page it works, but I can't get the HTTP 401 error to display. Thanks for the help. [code=PHP]if (!isset($_COOKIE['username'])) { header ('HTTP/1.0 401 Unauthorized'); }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14241-header-issue/ Share on other sites More sharing options...
kenrbnsn Posted July 10, 2006 Share Posted July 10, 2006 Put in an exit() statement following the header() function.[code]<?phpif (!isset($_COOKIE['username'])) { header ('HTTP/1.0 401 Unauthorized'); exit(); } ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14241-header-issue/#findComment-55923 Share on other sites More sharing options...
fuse3k Posted July 10, 2006 Author Share Posted July 10, 2006 Thanks for the reply kenrbnsn, I tried that earlier. It exits the script accordingly, but it does not display HTTP 401. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/14241-header-issue/#findComment-55926 Share on other sites More sharing options...
kenrbnsn Posted July 10, 2006 Share Posted July 10, 2006 Did you read the HTTP Specification at http://www.faqs.org/rfcs/rfc2616It looks like that code has other requirements. Did you try a 403 or 404?Ken Quote Link to comment https://forums.phpfreaks.com/topic/14241-header-issue/#findComment-55928 Share on other sites More sharing options...
fuse3k Posted July 11, 2006 Author Share Posted July 11, 2006 Yes, tried that too. Attempted to use 401, 403, 405, etc. None of them work. Also tried all using HTTP 1.0 and HTTP 1.1, to no avail.Is there something I should look to server-side that might prevent this function from executing?If not, I'll just spare the rest of the hair on my head and just rewrite the script. Quote Link to comment https://forums.phpfreaks.com/topic/14241-header-issue/#findComment-55935 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.