POST losing SESSION vars?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a page that will be redirected to a login page if the SESSION var
'authenticatedUser' is not set.

The page has a form in it.

When the page is loaded http://thePage the authentication works fine. When
the submit button is pressed it doesn't. With POST it acts as if the
required session var is not set.

When redirected to the login page the login page DOES recognize the the
session var and redirects back to the first page a logged in user would
usually see.

formPage.php
<?php
session_start();
if(!isset($_SESSION['authenticatedUser'])) {
$_SESSION['loginMessage'] = "You must first login.<br> ";
header("Location: index.php");
}
...

<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="POST"
name="purch_form" id="purch_form"
...
<input name="Submit" ...
</form>
?>


index.php
<?php
// FUNCTIONS
function logged_on($errorMessage) {
    header ("Location: authTest.php"); //tmp Loc while testing
}
function login_page ($errorMessage) {
        require_once "login.php"; //page where login pair entered
}
// end FUNCTIONS

// BEGIN authentication
session_start();
// First visit
if (!isset($_SESSION['loginMessage'])) {
        login_page("Registered users please login.");
        exit;
}
// PASS
if(isset($_SESSION['authenticatedUser'])) {
        logged_on("need some control here");
        exit;
}
// FAIL
else {
        login_page($_SESSION['loginMessage']);
        exit;
}
?>

In other words the same page should load after the submit button is pressed
but instead the authentication is redirecting.


Thanks for any help.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux