Alternative to HTTP Status Code 401?

I have a page that sends something to the server via AJAX. The server side of the script returns a status code 401 if the user is not registered or the user does not have the right to send messages. The problem is that the browser asks the user for a login dialog, and we have no way to suppress it. Is it possible to change 401 from 500? If not, what suitable, generic or custom code can I use instead?

+4
source share
1 answer

A was asked a similar question in Webmasters StackExchange. 401 is used for HTTP authentication, 407 is used for proxy authentication, and both are different from what you use, which is forms-based authentication. You can, of course, return 500 - Internal Server error when the user does not log in, however the post mentioned above recommends using 403 - Forbidden . A list of HTTP status codes and their meaning can be found here .

+4
source

Source: https://habr.com/ru/post/1446116/


All Articles