Zubrag.com :: Forum

zubrag.com => Password Protect Advanced => Topic started by: jon on February 17, 2008, 04:52:48 PM



Title: Automatic user logout when clicking on login.php
Post by: jon on February 17, 2008, 04:52:48 PM
When returning to the login page (login.php) after a user has logged in, it's blank unless the user first logs out.  Other than linking to "http://site.com/login.php?logout=1", is there a modification that could be made which would enable linking directly to login.php to automatically log out the current user, thus causing the page to again display itself?


Title: Re: Automatic user logout when clicking on login.php
Post by: Assis on June 04, 2008, 05:32:28 AM
I got the same problem with a blank page.
Did you find any solution? Please let me know.

Thanks
Assis


Title: Re: Automatic user logout when clicking on login.php
Post by: jon on June 04, 2008, 09:23:52 AM
No, I'm sorry, I've found no solution.  When a user has logged in, it seems the login page will always be blank (all white) until the user logs out.

As a workaround, I've changed all links to "http://site.com/login.php?logout=1", so that if anyone happens to be already logged in, they will automatically be logged out.  This works in all instances except for when arriving at the login page in a way other than by a link in a page that I've set up, such as hitting the browser back button.

I used this script for the Web site of a friend who needed my help.  If I had been working for a paying client, this problem would have rendered this script unacceptable, and I would have had to find a different method of protection.  As things stand, I won't use any script from this site again, as there seems to be no support other than from other users who are kind enough to try to help one another.

Good luck.


Title: Re: Automatic user logout when clicking on login.php
Post by: Druprider on September 29, 2008, 08:35:52 PM
As far as I'm concerned the script is perfect.
As per the support, you have to remember this script was done by 1 guy years ago.... and for free too! So I'm thinking if he's provided the script for free, provided support for free (way back then he was quite active!) and still made available a forum where people can help each other out.....and still no one's satisfied.... feel free to move on!!!

With reference to the blank login page, I had that same issue and discovered it to be due to the 'redirect url'. When a user registers or logs in, if there's no redirect url specified, it just hangs on the login.php blank page as the script doesn't know which url to direct the user too. I've hd to login to 'manager.php' and manually insert the page i want the user to be directed to e.g. welcome.php. Unfortunately this has to be done for each user that signs up. I'm still trying to find out how to configure it so all users automatically go to the same page.

Hope this helps. I'm a php newbie, but after tinkering and tinkering and reading and re-reading all the info on the php pages...i worked my way round it all and it works perfectly  on my site.


Title: Re: Automatic user logout when clicking on login.php
Post by: lift-n-lok on October 20, 2008, 11:18:12 AM
My users only see the login page when the first go to the site, the home page is protected so it brings up my customized login page then when the user goes back to the home page he's already logged in so he doesen't see the page again until his session times out.

I think you must have embedded the login into the home page, try moving your home page to your password folder and moving a copy of it without the login to your root folder.  This will be transparent to the user because they wont need the login the second time around.  If you do this it also gets rid of all the "bugs" that have been posted. 8)

If you do this it will then work the way it was writen to work.

This is an awsome script, one of the most usefull I have found.


Title: Re: Automatic user logout when clicking on login.php
Post by: Woody on December 25, 2008, 12:00:35 PM
Here is the solution to the white page problem when a user is already logged in:
Find this code in login.php (Mine was at the bottom of the page)

  if (!$found) {
    showLoginPasswordProtect("");
  }

and add this code after it

  // need to be redirected?
  if (isset($REDIRECTS[$key]) && !empty($REDIRECTS[$key])) {
    header('Location: '
           . ((REDIRECT_PREFIX != '') && (strpos($REDIRECTS[$key], 'http') !== false) ? '' : REDIRECT_PREFIX)
           . $REDIRECTS[$key]);
    exit();
  }

Now save it.

Works a treat for me!

Merry Xmas & Happy New Year!

Woody


Title: Re: Automatic user logout when clicking on login.php
Post by: 1ststop on September 17, 2009, 05:54:10 AM
As an answer to an earlier reply, with ref to the redirect address needing to be entered manually for each user: I have got around this quite easily. This works if you want everybody to redirect to the same address.

On the signup form, add a hidden field (instructions to add signup fields are found in the forum).

HTML for a hidden field is:

<input name="name_as_you_want" type="hidden" value="insert redirect address here. eg: home.php">

Then, in signup.php find this code on lines 25-30

function parse_user_input() {
    $this->login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
    $this->pass = $_POST['access_password'];
    $this->email = LOGIN_AS_EMAIL
                 ? $this->login
                 : (isset($_POST['access_email']) ? $_POST['access_email'] : '');

Add a new line to include your new information as below:
   

   $this->redirect = $_POST['name_as_you_want'];

This will add the new information to your 'users.php' variables.
Now, to include the information into the 'users.php' form find this code on line 102:

fputs($fusers, "\n" . $this->login. ',' . $this->pass . ',' . $this->email);

and modify it to look like this:

fputs($fusers, "\n" . $this->login. ',' . $this->pass . ',' . $this->email. ',' . $this->redirect);

Now the 'value' from your hidden form input will be added to your 'users.php' array.





Title: Re: Automatic user logout when clicking on login.php
Post by: Jonni on May 11, 2010, 10:49:12 AM

Or even easier if you have php on your server

let it to check whether someone is logged in and if they are change the login link to a logout link.

Code:
<?php
 
if (isset($_COOKIE['verify']) && !empty($_COOKIE['verify'])) {
  
// user is logged in, show logout link
  
echo "<a href=address/to/login.php?logout=1'>Logout</a>";
  } else {
echo "<a href='address/to/login.php'>Login</a>";
}
?>



Title: Re: Automatic user logout when clicking on login.php
Post by: ragtech on August 13, 2012, 04:00:36 PM
It pays to browse/search for your answers!


Thanks for this!
Regards,
~ragtech
U.S. Website Creations (http://www.uswebsitecreations.com/)