Logout button

When using session based authentication on the web, it is possible to create a logout button in a simple way.

Just append ?logout to the URL path. By using redirectto it is possible to forward the user to a logout page. Only catch, since you then are logged-out, the page you want to show must be available for the user anonymous.

Just create a button with the the following syntax in the onClick event:
window.open(pathToDb + "?logout&redirectto=//" + logoutURI ,"_self")

“_self” opens the url in the current window.

Pitfalls:
If you want to redirect to the same application (logout and get the login dialog directly) don’t forget to end logoutURI with a slash “/”.

This would logout and direct you to the login page again:
window.open("//ldserver.com/webapps/testdb.nsf?logout
&redirectto=//ldserver.com/webapps/testdb.nsf/","_self")

Advertisement