Zubrag.com
April 28, 2017, 09:25:17 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Adding Logout link  (Read 104909 times)
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« on: June 15, 2007, 03:39:38 PM »

Password Protector will automatically logout user when browser is closed (if TIMEOUT_MINUTES is set to 0).
But script also supports a manual logout feature which you may find useful.

In order to implement manual logout feature you'll have to accomplish following steps:

1. Setup logout URL in the script

If you look at the password_protect.php source code you'll see following

// User will be redirected to this page after logout
define('LOGOUT_URL', 'http://www.example.com/');

2. Add Logout link on your website

Add following HTML code on your site pages wherever you want a logout link to be shown

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

Upon logout script will redirect user to the URL you specified on step 1.

Logged
sabotage
Newbie
*
Posts: 4


« Reply #1 on: June 18, 2007, 09:43:54 PM »

Very useful thanks!!!
Logged
dmax
Newbie
*
Posts: 4


« Reply #2 on: June 21, 2007, 02:59:26 PM »

Script works great. Also installed logout script which is exactly what i needed. There is 1 small problem, after logout if I hit the browser back button it takes me right back into the protected page I just logged out of.  Is there a way to fix this.  Cheers, -d
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #3 on: June 21, 2007, 03:36:07 PM »

Browser cached protected page. Add following code to all protected pages (to avoid caching):

  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

The code needs to be placed somewhere between <head> and </head> tags.

For example page's HTML code was

<html>
<head>
  <title>Custom Title</title>
</head>
...

after change it would be


<html>
<head>
  <title>Custom Title</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
...
Logged
dmax
Newbie
*
Posts: 4


« Reply #4 on: June 21, 2007, 07:16:45 PM »

I tried this and it doesnt seem to work. Before I copied the script into my file, I converted the script into php.
Here's what it looks like inside my protect php page.

echo "  <head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
echo "<META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\"><META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n";
echo "  \n";
echo "  \n";
echo "\n";
echo "<body>\n";
echo "    <meta name=\"Generator\" content=\"iWeb 1.1.2\" />\n";
echo "    <title>Calendar_1</title>\n";
echo "    <link rel=\"icon\" href=\"favicon.ico\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"Calendar_1_files/Calendar_1.css\" /><script type=\"text/javascript\" src=\"Calendar_1_files/Calendar_1.js\"></script>\n";
echo "  </head>\n";
Logged
dmax
Newbie
*
Posts: 4


« Reply #5 on: June 21, 2007, 07:26:33 PM »

Would it be easier to adjust the log out script so the redirect page ('LOGOUT_URL', 'http://www.example.com/');  opens in a new browser window?  If yes, how would I do this? Thank You! Cheers, -dmax
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #6 on: June 22, 2007, 04:15:29 AM »

Currently you have body tag inside header. This is not correct. Move echo "<body>\n"; after the </header>.

In order to open in a new browser window add target="_blank" to the logout url, like this:

<a href="http://www.example.com/path/to/protected/page.php?logout=1" target="_blank">Logout</a>
Logged
dmax
Newbie
*
Posts: 4


« Reply #7 on: June 22, 2007, 10:16:40 AM »

Hi, sorry for the trouble. It's still allowing the back button in safari browser to take me back into the secure page. Here's the code, I'm sure there's something wrong.

<head>
      <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
      echo "
      <META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\">
      <META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n";
      echo "  \n";
      echo "  \n";
      echo "\n";
      echo "
      <meta name=\"Generator\" content=\"iWeb 1.1.2\" />\n";
      echo "
      <title>Calendar_1</title>\n";
      echo "
      <link rel=\"icon\" href=\"favicon.ico\">\n";
      echo "
      <link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"Calendar_1_files/Calendar_1.css\" />
      <script type=\"text/javascript\" src=\"Calendar_1_files/Calendar_1.js\"></script>\n";
      echo "
   </head>\n";
   echo "
   <body>
      <body style=\"background: transparent url(Images/bckgrnd2.jpg) repeat scroll top left; margin: 0pt; \" onload=\"onPageLoad();\">\n";
         echo "
         <div style=\"text-align: center; \">\n";
            echo "
            <div style=\"margin-bottom: 0px; margin-left: auto; margin-right: auto; margin-top: 0px; overflow: hidden; position: relative;  background: transparent; text-align: left; width: 800px; \" id=\"body_content\">\n";
               echo "
               <div style=\"float: left; margin-left: 0px; position: relative; width: 800px; z-index: 0; \" id=\"nav_layer\">\n";
                  echo "
                  <div style=\"height: 0px; line-height: 0px; \" class=\"tinyText\"> </div>\n";
                  echo "
               </div>\n";
               echo "<a href=\"http://www.midnightlighting.com/Calendar.php?logout=1\">
                  <img src=\"Calendar_1_files/shapeimage_1.png\" alt=\"LOG OUT!\" title=\"\" id=\"id2\" style=\"height: 47px; left: 306px; position: absolute; top: 1px; width: 187px; z-index: 1; \" />\n";
                  echo "
                  <div style=\"height: 50px; line-height: 50px; \" class=\"tinyText\"> </div>\n";
                  echo "
Logged
tinem
Newbie
*
Posts: 3


« Reply #8 on: November 11, 2007, 09:12:51 AM »

First I like to thank you for this great script. I just have some problems that when closing the browserwindow it doesn't clear the access and I have put this code in the passwordprotected file as you suggest like this:
   <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
     <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

It's working if I click the Logout link but is there a way to get it functioning when closing the browserwindow beside what I have done?

Click on the map link from this site http://www.tinemuller.dk/Saving_User-Added_Form_Data/ and login as admin - adminpass and then you can see what I'm talking about.

Do you have a script for password protect a folder?

Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #9 on: November 12, 2007, 07:37:23 AM »

Hi. I tried that url in IE and Firefox. Both logged out when i closed browser. What browser you are using?
Logged
tinem
Newbie
*
Posts: 3


« Reply #10 on: November 12, 2007, 07:47:37 AM »

Thanks for your quick reply.

Firefox 2.0.0.9 it's not functioning but Explorer 6 it's OK. I use xp pro if it matters. After you close the browser window try pasting the adress http://www.tinemuller.dk/Saving_User-Added_Form_Data/phpsqlinfo_add.php again and you will se the problem.

What about my other question about password protect a folder?

Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #11 on: November 12, 2007, 09:27:11 AM »

I have 2.0.0.9. Opened that page, logged in, closed browser. Opened page again. Login dialog appeared. Not sure why your Firefox is working differently. I'm on XP pro also. Maybe firefox cached page. Try Ctrl+F5 on that page afte you log in.
Logged
tinem
Newbie
*
Posts: 3


« Reply #12 on: November 12, 2007, 10:26:17 AM »

It's still the same. So maybe I should leave out close the browser and only have click logout?

If you don't have a script for password protect a folder please tell me yes og no?
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #13 on: November 12, 2007, 11:12:42 AM »

Sorry, forgot to answer that one. No specific script for protecting folders, unless you protect each file in the folder using password protector. If you want to protect a folder try using .htaccess protection (should be some 'protect folder' menu in your webhosting account management to do that).
Logged
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC