Peter,
   I had a similar problem, and I believe there's a bug report already
filed about it.  PHP doesn't seem to save session variables if you use
the "Location:" header.  What I do in my scripts when I need to set a
location redirect is run 'session_write_close()' before I use the header
function.  This assures me that the data is written.

Jaime Bozza


-----Original Message-----
From: Peter Lavender [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 15, 2002 7:35 PM
To: php-general
Subject: [PHP] session problems not finding my variables..


Hi everyone,

I'm not sure what I have done wrong here.  I haven't been sucessful in
finding anything that points to what the cuase could be.

What I find interesting is that I have used session in another area of
the web site with out problems.  The only difference between it and the
way I have done it here is that I'm using the header function in this
bit of code, where as the session is started and variables registered
and the processing is done on another page.

Anyway here is the code for the log in page:

<?php
session_start();
file://session_unset();

include('./connectDB.php');
include('./commonfunctions.php');
?>

function checkdetails($db, $HTTPVARS) {
    //check if allowed access
    $user = $HTTPVARS['uid'];
    $passwd = $HTTPVARS['passwd'];

    $sql = "select * from tbl_maxware where loginID = '$user' and
password = '$passwd';";
    $result = $db->query($sql);
    checkError($result, $db, "Error in checkDetails");

    if ($result->numrows() == 0) {
        echo "<html><body>";
        echo "<h2>Error Loging In</h2>";
        echo "<br>Not a valid login try again or contact the admin<br>";
        echo "<a href=\"./login.php\">Try Again</a>";
        echo "</body></html>";
        exit();
    } else {
        // matched in the maxware table
        $result->fetchinto($success);
        $UID = $success[0];
        $logUID = $success[1];
        $logName = $success[2];
        //echo session_save_path();
        session_register("UID", "logUID", "logName");
        // send them to the main page
        header("Location: ./supportau.php");
    }

} // end checkdetails

if (array_key_exists( "uid", $HTTP_POST_VARS ) ) {
    checkdetails($db, $HTTP_POST_VARS);
} else {
    login();
}
?>



Code for the following "main page"

<?php
session_start();
include( './connectDB.php' );
include('./commonFunctions.php');
?>
<html>
<head>
<title></title>
<DEFANGED_style>
    <!--
        @import url(./max.css);
        @import url(./supportAU.css);
        @import url(./link.css);
    -->
</DEFANGED_style>
</head>
<body>
<h2>Support Database</h2>
<center>
<table width="90%" border="1">
<tr><td rowspan="2" width="30%">
<!--<table width="100%" border="1" bgcolor="#887766">
<tr><td> -->
<?php
echo "Name= $logName";



<DEFANGED_snip>

This returns an error:

 PHP Warning: Undefined variable: logName in
c:\inetpub\wwwroot\supportau\supportau.php on line 25

Thanks,

Pete




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to