Zubrag.com
May 20, 2012, 11:38:04 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]
  Print  
Author Topic: Automatic Logout & Redirect  (Read 2036 times)
TracyS
Newbie
*
Posts: 1


« on: October 12, 2007, 03:35:46 pm »

I am attempting to use this script to force login when accessing a specific page. This page is designed for a call center to be able to login through the website and place orders for customers who call after our normal business hours.  I am running into two problems though:

1. It never seems to log out. I set the time to 15 minutes and I commented out this line of code
setcookie("verify", '', $timeout, '/'); // clear password;
Neither one has resulted in being prompted for the password for any reason other than closing out and re-opening the browser.

2. I need to create a "smart code" bit of PHP for a log out feature.

Basically, when a call center employee answers a call for us, they will go to a specific URL and "Log In" (thanks to your script!)

They are then able to find existing customers or create new accounts and place an order for the customer.

After the order is placed, I would like for it to automatically take them back to the specific URL and force them to Log In again for the next caller.

The fun part is this - they are using the same website pages that any other customer would be using to submit their order. Therefore, I don't want to have a "logout" text link as it would be confusing to our customers. I also don't just want to automatically redirect people to the "Log In" (password_protect.php) page as our Internet customers would end up there after placing an order too.

So I need to be able to use some PHP in the final page to basically check if they are logged in via the password_protect.php feature, and if so - log them out and redirect them to the URL again where they would log in for the next call. If they aren't logged in via the password_protect.php page, then it would do nothing.

Any thoughts on how to accomplish this?

Thank you,
Tracy

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


WWW
« Reply #1 on: October 15, 2007, 04:06:57 am »

Hi
It never seems to log out. I set the time to 15 minutes and I commented out this line of code
I suspect it depends on the server time and user's time. Is there a difference between them in your case, like server is 1 hour behind your time?

to use some PHP in the final page to basically check if they are logged in ...
I think adding following code to the final page php would help. It will redirect only if logged in via password protector.

// check if password cookie is set
if (!isset($_COOKIE['verify'])) {
  // log out user
  setcookie("verify", '', 0, '/'); // clear password;
  header('Location: PUT-LOCATION-HERE');
  exit();
}
Logged
Pages: [1]
  Print  
 
Jump to:  

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