00 Votes

HTTP Status Code for Redirection to Logout Page after Timeout

Question by Guest | 2016-06-12 at 09:36

If one of my users was not online for a longer time and if the user is then trying to show one of his personal pages, he will be logged out automatically (most website are handling it in this way).

Now, my question is, which HTTP Response Code I should use for this redirection for sending to the browser. Finally, there is the situation that the user is calling for specific page and he will be redirected to another page.

Up to now, I have used the status code "301 Moved Permanently" in this situation. However, some users have told me that this code has an unwanted effect in some cases: for example, the Android Firefox browser seems to recognize this redirection so that you will be automatically logged out when trying to show a page from which you have been logged out and redirected so far. Of course, this is a disaster!

So, I wonder how I could solve this best. Which code is adequate to be sent together with a redirection to the log-out page after a timeout?

ReplyPositiveNegative
0Best Answer0 Votes

The code "301 Moved Permanently" is indeed not fitting very better. It says that the requested content is moved permanently to another URL and that the content will be available under that URL from now on and forever.

Instead, I would recommend sending the HTTP Status Code "302 Found". This code says that the requested content will be available under another URL only temporarily and that you should remain using the old URL in future. The statement is, that the requested URL is existing (found) but that you have to go a detour temporalily. I think this is fitting best in this situation.

Here is an excerpt from the original status code definitions by w3.org:

301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

302 Found 

The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. 
2016-06-13 at 04:57

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.