Felogin logout redirect does not work

When we try to logout from an access restricted page, we will see either a 404 (Page not found) or a 401 (Authorization required) error.
This issue seems quite old, but unfortunately there are still some bugs when we use the Logout template of the felogin.

The issue is reproduceable even on Typo3 4.2.8, I am not sure if this is fixed on 4.3 onwards.

There is a patch that we can use to patch felogin as given on the following URL:
http://bugs.typo3.org/view.php?id=8677

Due to various reasons it may not always be possible to patch.
In such circumstances it is wiser to use an alternate technique, such as creating the Logout link manually.
One such example is:

[loginUser = *]  

lib.logoutbox = COA
lib.logoutbox {
    20 = TEXT
    20 {
       data = TSFE:fe_user|user|username
       # link to account edit page
       stdWrap.typolink.parameter = 60
    }
    30 = IMAGE
    30 {
        file = fileadmin/templates/images/logout.gif
        stdWrap {
             
             # Let us link to home page for logging out
             typolink.parameter = 1
             typolink.additionalParams = &logintype=logout
             wrap =  |
         }
    }
}

[end]

In this example I am displaying the logged in username (which links to user account page) followed by a working logout button.

Note:
– Here we are not using the felogin plugin.
– Do not link the logout button to any access restricted page.

The following page from Typo3wizard might be useful for displaying more user-details if needed:
http://www.typo3wizard.com/en/snippets/cool-stuff-typoscript/userinfo-for-currently-logged-in-user.html