Jump to content

Archived

This topic is now archived and is closed to further replies.

fuse3k

Header issue.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Put in an exit() statement following the header() function.
[code]<?php
if (!isset($_COOKIE['username'])) {
    header ('HTTP/1.0 401 Unauthorized');
    exit();
    } ?>[/code]

Ken

Share this post


Link to post
Share on other sites
Thanks for the reply kenrbnsn,

I tried that earlier. It exits the script accordingly, but it does not display HTTP 401. Any ideas?

Share this post


Link to post
Share on other sites
Did you read the HTTP Specification at http://www.faqs.org/rfcs/rfc2616
It looks like that code has other requirements. Did you try a 403 or 404?

Ken

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.