
October 11th, 2003, 09:37 PM
|
 |
Contributing User
|
|
Join Date: Mar 2003
Posts: 319
Time spent in forums: 1 Day 3 h 8 m 32 sec
Reputation Power: 6
|
|
|
Malfunctioning Login/Logout
These scripts do not seem to work properly. Sometimes on entering the correct user/password, it simply keeps defaulting back to the login page. Sonetimes if i click the login button with no info in the user/pswd, it gives me an existing session on a page. And when i try to move onto another page (each location has 2 pages) it defaults back to the login page. The only time it seems to work ok is when i access all pages directly, and if they give me access i specifically logout of them one by one. I guess i need to destroy the session at some point in the Logout script, how would i do that without logging out any other user that may have also signed in?
Or if anyone has any better suggestion of doing this login/logout, please let me know. Thanks
Login.php
PHP Code:
<?php
//verify if the user/pw iscorrect
session_start();//start a session
if (($_POST['f_user'] == "Ams") && ($_POST['f_pass'] == "111") && ($_POST['City'] == "AMS"))
{
$_SESSION['AMS'] = "AMS";
//session_name("AMS")
header("Location: http://www....com/AMS/Ams/UpdateCurrencyAms.php");
}
elseif ((isset($_SESSION['AMS'])) && ($_SESSION['AMS'] == "AMS"))
{
header("Location: http://www....com/AMS/Ams/UpdateCurrencyAms.php");
}
elseif (($_POST['f_user'] == "Ant") && ($_POST['f_pass'] == "222") && ($_POST['City'] == "ANT"))
{
$_SESSION['ANT'] = "ANT";
header("Location: http://www....com/ANT/Ant/UpdateCurrencyAnt.php");
}
elseif ((isset($_SESSION['ANT'])) && ($_SESSION['ANT'] == "ANT"))
{
header("Location: http://www.....com/ANT/Ant/UpdateCurrencyAnt.php");
}
elseif (($_POST['f_user'] == "Prg") && ($_POST['f_pass'] == "333") && ($_POST['City'] == "PRG"))
{
$_SESSION['PRG'] = "PRG";
header("Location: http://www.....com/PRG/Prg/UpdateCurrencyPrg.php");
}
elseif ((isset($_SESSION['PRG'])) && ($_SESSION['PRG'] == "PRG"))
{
header("Location: http://www....com/PRG/Prg/UpdateCurrencyPrg.php");
}
elseif ((!isset($_POST['f_user'])) || (!isset($_POST['f_pass'])) || (!isset($_POST['City'])))
{
header("Location: http://www....com/Login.htm");
}
else
{
header("Location: http://www..../Login.htm");
}
?>
Logout.php
PHP Code:
<?php
session_start();
if ($_GET['City'] == "AMS")
{
if ((isset($_SESSION['AMS'])) && ($_SESSION['AMS'] == "AMS"))
{
// remove the 'AMS' session var
unset($_SESSION['AMS']);
header ("Location: http://www.....com");
}
else
{
header ("Location: http://www....com");
}
}
elseif ($_GET['City'] == "ANT")
{
if ((isset($_SESSION['ANT'])) && ($_SESSION['ANT'] == "ANT"))
{
// remove the 'AMS' session var
unset($_SESSION['ANT']);
header ("Location: http://www.....com");
}
else
{
header ("Location: http://www....com");
}
}
elseif ($_GET['City'] == "PRG")
{
if ((isset($_SESSION['PRG'])) && ($_SESSION['PRG'] == "PRG"))
{
// remove the 'PRG' session var
unset($_SESSION['PRG']);
header ("Location: http://www.....com");
}
else
{
header ("Location: http://www....com");
}
}
?>
Here is the check on each page to check for an existing session
Ams.php
PHP Code:
<?php
session_start();
if ((!isset($_SESSION['AMS'])) || ($_SESSION['AMS'] != "AMS"))
{
header("Location:http://www......Login.htm");
}
else
{
?>
<html>
<head>
...rest of page...
<a href="../../Logout.php?City=AMS">LogOut</a>
.......
<?php
}//end else
?>
Last edited by PHPme : October 11th, 2003 at 09:44 PM.
|