Adding Logout link

Started by zubrag, June 16, 2007, 12:39:38 AM

nikwit

Hello and thank you for such a great piece of code to add to my site.

I hope you'll forgive my ignorance, but this is the very first piece of php code I've written (I've developed other code - but that was 3 years ago)!

In the link for the logout you have the user redirected to page.php

<a href="http://www.example.com/path/to/protected/page.php?logout=1">Logout</a>

I'm not sure what to do with the parameter
logout=1
in order to actually log them out.  Do you have an example of this page as well?

Thanks a bunch!

zubrag

Hi. You do not need to add code. Protected page will logout automatically when "logout=1" parameter passed (as logout functionality is implemented in protection script).

dandrianjafy

Hi, I am trying to add th elogout link as per your instruction at the top of this thread, but cannot find the line you indicated in point 1.  All I can find within password_protect.php is // User will be redirected to this page after logout
define('LOGOUT_URL_ADMIN', isset($_SERVER['HTTP_REFERER']) ? str_replace('?logout=1','',$_SERVER['HTTP_REFERER']) : '');  Is this the right one, and where would I add the redirect URL?

Cheers

zubrag

Hi. You have to place logout url on your page (where you want it to appear). For example, if you protected members.php then you have to add logout url to members.php.

Lets say page contents was
<?php

echo "<p>This is protected page</p>";
echo "<p>Some more text here</p>";
....

?>

then you can add url as follows

<?php
echo '<a href="http://www.example.com/path/to/protected/page.php?logout=1">Logout</a>';
echo "<p>This is protected page</p>";
echo "<p>Some more text here</p>";
....

?>

So you have to put it anywhere on your page.

dandrianjafy

Thanks for your quick support.  I have added the link as you instructed, but when clicked on it takes me to this - You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.

These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.

How can I redirect to my logout confirmation page?

cheers

zubrag

I provided this link just for example
<a href="http://www.example.com/path/to/protected/page.php?logout=1">Logout</a>

Change url to match your protected page url.

dandrianjafy

Sorry, I think I must be a little thick when it comes to this.  I have copied your example link and added the path as per my protected page and it still goes to the same place as I mentioned above.  The protected page you mention...is that the logout confirmation page or the page on which the logout link is on?  I have put the same address as the lougout link is on.

Chhers

zubrag

Protected page stands for any page protected using password protector. You could also link to login.php instead of protected page.
For example you have login.php in http://www.example.com/members/login.php
Logout url could be <a href="http://www.example.com/members/login.php?logout=1">

When user click on that url, password protector will automatically check parameter, and if it is logout=1 then it will redirect to url specified in the settings.php as logout url (from what you posted you seems to be using advanced password protector). Simple password protector has logout url defined in the script code (password_protect.php).

Advanced password protector has its own section as it differs from simple one: http://www.zubrag.com/forum/index.php/board,17.0.html

dandrianjafy

Damn you're quick  ;)

Yes I am using Advanced Password Protect.  Does that mean I need to do anything differently?

zubrag

They differ in user management (advanced has user management functionality, signup, etc) and settings (different files contain settings), but login/logout functionality is almost the same. So above info is good for both (except for you cannot link to login.php in simple protector as it does not have such program).
Updated my post above to be more descriptive.

dandrianjafy

Thanks for all of your help.  The support for this script is excellent

anaz

Hi:

I am using your script (its wonderful) however I have a question. If a user logsout more then once in the same session (same browser), the logout does not work (it takes the user to the redirected page) but the user is not actually "logged" out. Next time user clicks on the link it doesnt ask for the password...(again this only occurs if user logsout more then once in the same session/same browser). I am guessing it might have to do with logout=1 in the script...is there a way to reset the logout variable after its=1.

Thanks

testmen

Has anyone got this logout link to work yet??

I have the no cache lines in the document head, ?logout=1 in the logout link, etc, etc. But like many others, my browser back button brings me right back onto the protected page again.


dgow

The password protect script works great. No problem there.  I even added the login to my own login.php page.  Looks great in the web editor, (expression web 2), but never shows up on the website.  When I added the logout link to the password protect page some strange things start to happen.  I am not adding something in right.

I click to enter the password protected page and it takes me to the login page, not the login.php page I created.  I login and I get the password protected page as designed.  But when I click the logout text it takes me back to the page I setup, but without any of the graphics.  Furthermore when I click any of the links from that page, all the pages have NO graphics on them anymore.

What am I not adding in correctly?

Link:   http://www.mbiweb13.com/customer_accounts.php

Click on "Sincerely Yours" & use the "zubrag & root" as password.