Logout button on masterpage, or logout custom code

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
madjamonline
 
 
Posts: 51
Joined: Tue Jun 19, 2007 4:27 pm
Location: United Kingdom
Contact:

Logout button on masterpage, or logout custom code

Post by madjamonline »

Hello everyone,
Has anyone ever wanted to put the logout button on the master page but it never works when you actually try?

Well then, follow these simple steps to work around this!

1. Create a new page and call it logoutprocess
2. MAKE SURE THE EXTENSION IS SET TO PHP!
3. Go to Page > Page HTML
4. Choose Start of Page
5. Enter this:

Code: Select all

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
   session_start();
   unset($_SESSION['username']);
   header("Location: ./logoutsuccess.html");
}
?>
(Make sure you have a page called logoutsuccess.html! You can always change the page in the coding. This page could say something like "You have been logged out" or it could be the homepage of your site.)

If some people want to go the extra mile like I have on my client area, you can make it so when someone logs out, it has a banner saying logging out.

To complete this:
1. Insert a layer that covers the whole page width and a height of about 80.
2. Open Properties for the Layer and enter in the Right box, 10.
3. Make sure there is a margin for the layer from the top and left of 10 pixels.
4. Go to the Layout properties of the Layer, choose a nice background colour and border.
5. Go to the coding in the Start of HTML and remove the header("Location: line
6. Go to Page Properties > Misc and enter a redirect page with about 3 - 5 second delay.
7. Put a text object in the center of the layer saying something like "You are being logged out"
8. Put a link in the text that says "Click if you are not redirected" so the user can click it if they are not redirected.

The finished piece should look like this:
Image

I hope this helps people!
Post Reply