Re: Help debugging a session issue

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

 



In message <eu598e+1tei@xxxxxxxxxxx>, teacherweeks
<teacherweeks@xxxxxxxxx> writes
>I am trying to figure out why this session variable is not passing
>from one page to another, the first page handles the security
>processing. The second page is a block of code for a snippet on pages
>to check for authentication.  I am not including all the code, simply
>the relavant portion. The second page is giving me an undefined index
>error. Thank you to anyone that can help me.   David
>
>if ($num !=0) {
>       session_start();
>       session_register('loginusername');
>if (isset ($_SESSION['loginusername']))
>       $_SESSION['auth'] = 1;
>       $_SESSION['loginusername'] = $username;
>       header("Location: ../newlogin/username.php");
>       }
>       else {
>       print "<h3> Unauthorized Login </h3> <br><br><a
>href='../newlogin/login.php'>Please Try Again</a>";
>       exit;
>}
>
>----------
>
><?
>session_start();
>if ($_SESSION['loginusername'] == 1) {
>       print $_SESSION['loginusername'];
>} else {
>       print "Not Logged In";
>       }
>?>

The line:
>if ($_SESSION['loginusername'] == 1) {

Should'nt that be 
>if ($_SESSION['auth'] == 1) {

This is very tacky, but if I get stuck, I paste this in...
  echo "<br />------------------------------------<br />";
  echo "GET:<br />"; var_dump($_GET); 
  echo "<br />POST:<br />"; var_dump($_POST);
  echo "<br />SESSION:<br />"; var_dump($_SESSION);
  echo "<br />------------------------------------<br />";

and it makes a lot of silly mistakes very easy to spot.

-- 
Pete Clark

Sunny Andalucia
http://www.hotcosta.com/comm_1.htm

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux