Kevin_M_Schafer
04-05-2011, 06:22 PM
Hello,
I'm trying to build a logout button, accomplishing the top execution with the button code below it. How do I do something like this? It has me puzzled.
<a href="/member/frontend/logout.php">Logout</a>
<FORM><INPUT TYPE="BUTTON" VALUE="button text here" ONCLICK="window.location.href='http://mysite'"></FORM>
Kevin_M_Schafer
04-05-2011, 06:25 PM
I should have said this:
When a person is on a permission-granted page, I want them to be able to click "Logout" and then be automatically redirected back to my home page. I should have said that right away. Sorry.
teedoff
04-05-2011, 06:28 PM
Set the form action to the page you want the users to land on.
<form action="http//:www.myhomepage.com"></form>
I guess thats all you're asking right?
Kevin_M_Schafer
04-05-2011, 10:20 PM
Teed,
What about the logout part with the PHP?
quartzy
04-06-2011, 02:52 PM
I googled it and found this http://www.plus2net.com/php_tutorial/php_login_logout.php
teedoff
04-06-2011, 02:57 PM
As quartzy pointed out, since php is an open source, there are probably tons of free login/logout scripts and tutorials online.
eberdome
04-07-2011, 04:58 AM
An example of a logout page can be as follows: (simply put)
logout.php
<?php
session_destroy();
header ('Location: http://your-redirect-page.com/');
?>
When a user clicks the logout link, it will automatically send them to your desired page instantly, and clear the session (logout the user).
But in order for this to work, a session needs to be started from the get go!!
munkeyboy
04-07-2011, 05:17 AM
Assuming we are attempting to log out of a PHP Session; from a security perspective I've found it safer to re-initialize the Session rather then merely destroying it before logging out.
session_start();
//set some $_SESSION[$values]
$_SESSION = array();
session_regenerate_id(true);
session_destory();
In this manner the first Session is replaced with a second, empty, Session before logging out to remove all traces of the first Session.