SyntaxFix
Write A Post
Hire A Developer
Questions
The header() function has a parameter for status code. If you specify it, the server will take care of it from there.
header()
header('HTTP/1.1 401 Unauthorized', true, 401);
See Gajus' answer: https://stackoverflow.com/a/14223222/362536