I have a page that posts something to the server via AJAX. The server side script returns status code 401 if the user is not logged or if the user has no right to post. The problem is, the browser prompts the user with a login dialog and we have no power to suppress that. Is it okay to alter 401 with 500? If no, what appropriate, generic or custom code can I use instead?
Share
A similar question was asked on the Webmasters StackExchange. 401 is used for HTTP authentication, 407 is used for proxy authentication, and both are different from what you are using which is form-based authentication. You could certainly return
500 - Internal Server errorwhen the user is not logged-in, however the post I mentioned recommends using403 - Forbidden. A list of HTTP status codes and their meaning can be found here.