William Piper wrote:
> Wade Smart wrote:
>>
>> Wade Smart wrote:
>>  > William Piper wrote:
>>
>>  >> what does print_r($_SESSION); show?
>>  >
>>  > 20080724 1508 GMT-6
>>  >
>>  > Nothing. Its shows nothing.
>>  > session_start() is the first line and Im not doing anything I haven't 
>> done
>>  > before. I'm clearing my cache (which shouldn't affect this) to see if 
>> it helps.
>>  >
>>  > I'm a bit puzzled.
>>  >
>>  > Wade
>>
>> 20080724 1516 GMT-6
>>
>> I wiped my cache and deleted my cookies. Now print_r() shows the correct 
>> values.
>> Funny thing: still evaluating wrong.
>>
>> page1.php
>> if($key === $u && $code === $p){
>> $_SESSION['authorized'] = "yumyum" ;
>> header("Location: page1.php");
>>
>> page2.php
>> if($_SESSION['authorized'] != "yumyum" ) {
>> header("Location: http://www.google.com <http://www.google.com>");
>> }
>>
>> print($_SESSION)
>> 'authorized' = "yumyum"
>>
>> I must be losing it today as this cant be that hard :)
>>
>> Wade
>>
> 
> Here are a few points to throw out there:
> 
> - I don't know if that was a typo or what, but you have:
> header("Location: page1.php"), so wouldn't that point to itself instead 
> of page2?
> 
> - Are $u and $p boolean? If not you should be using == instead of ===
> 
> - On page2, you will only go to google if yumyum is NOT in session.
> 
> bp

Maybe I should be more detailed:

user_login.php calls two files: header.htm and footer.htm.
At the top of my header.htm file is
<?php
session_start();
ob_start();
?>


On my user_login.php page I have the username and password fields and it 
reposts 
back to itself.

I then have get the posted vars to a local far:
$u = $_POST['username'];
$p = $_POST['password'];

for now Im not getting the infomration from the db on the user. Im just using 
temp values so I have this:

$key = "name";
$code = "password";                                     

and then I compare them:
if($key === $u && $code === $p){
   $_SESSION['authorized'] = "yumyum";
   header("Location: auth_home.php\r\n");
}


Now, on the auth_home.php page, it calls at the top header.htm with the 
session_start() at the top. Then I have this code:

        if($_SESSION['authorized'] == "yumyum" ) {
                break;
        } else {
                //header("Location: user_login.php\r\n");;
        }


At the moment I have put
print_r($_SESSION); at the bottom of the auth_home.php page.

When I put in the incorrect username and password the page will not change. 
Which is what I want. When I put in the correct data I get transfered to 
another 
page. Which is what I want. If I clear all session variables and go directly to 
the auth_home.php page I should be redirected back to the user_login.php page 
but Im not. So, the session variable is not evaluating.

Oh, and to James asking about error reporting, I have
        ini_set('display_errors', 1);
        error_reporting(E_ALL);
under session_start(); for debugging.

Wade

Reply via email to