I’ve got an "Admin Login" link in my webpage footer, which takes the user to the manager login screen (allowing the client to login to the manager). I would like that link to change to "Admin Logout" if the client is logged in, providing a quick way to logout from the frontend. Providing the correct link text is simple enough with a basic snippet, but how can I actually make the logout happen when the link is clicked? Is there a logout function I can call, or is there a better method?
Any ideas please?
bump... thought this would have been pretty simple...
I can think of a few possible ways to do that. For instance:
- unset the manager SESSION variables, e.g. unset($_SESSION[’webUser’]); etc. (a bit tedious)
- destroy and restart the session: session_destroy(); startCMSSession(); (logs out web user as well though)
- use the url that is used within the manager as well ./manager/index.php?a=8 . In that case you would have to handle the referer though (didn’t try that yet).
In all cases you would need to send the user to a php script, which then sends the user back to a page (e.g. home), once logged out.
This will work as a logout link if you have weblogin (might work with login as well):
<a href="[~12~]?webloginmode=lo">Logout</a>
Replace 12 with the ID of your login page.