Jump to content


Photo

Header issue.


  • Please log in to reply
4 replies to this topic

#1 fuse3k

fuse3k
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 July 2006 - 11:24 PM

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.

if (!isset($_COOKIE['username'])) { header ('HTTP/1.0 401 Unauthorized'); }


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 10 July 2006 - 11:37 PM

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

Ken

#3 fuse3k

fuse3k
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 July 2006 - 11:44 PM

Thanks for the reply kenrbnsn,

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

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 10 July 2006 - 11:54 PM

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

#5 fuse3k

fuse3k
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 July 2006 - 12:21 AM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users