I'm passing on some information from one page to another with the $_Session variable. It works fine for user_logged, username. But for the uidno I get a strange result. The output is an array with Array ( [0] => 6 [idno] => 6 ). I'd expect a simple 6.
The values come from a table with 3 columns (idno, name, password). Any help is appreciated.
$getidSQL= mysql_query("SELECT idno FROM users WHERE name='$enteredlogin'");
$checkpasswordSQL=mysql_query("SELECT password FROM users WHERE name='$enteredlogin'");
$useridentity=mysql_fetch_array($getidSQL);
$pw= mysql_fetch_array($checkpasswordSQL);
if (!$enteredlogin=="" ) {
//check password and move on if correct
if ($enteredpassword==$pw[0] AND !$useridentity=="") {
session_start(); //start the session
$_SESSION['user_logged'] = true; // user logged in
$_SESSION['username'] = $enteredlogin;
$_SESSION['uidno'] = $useridentity;
header('Location: cattable.php');
cattable.php:
if (session_id() == "") session_start(); // if no active session we start a new one
if (!$SESSION['user_logged']==1) { echo "Not logged in"; header('Location: index.php');}
echo $SESSION['user_logged'];
echo $SESSION['username'];
echo $SESSION['uidno'];
echo"<BR>";
print_r($_SESSION);
The output is:
Array ( [user_logged] => 1 [username] => dickreuter [uidno] => Array ( [0] => 6 [idno] => 6 ) )
The first two variables contain exactly what they should. But I don't understand why the uidno ends up being an Array. What is even more surprising is that when i put echo $_SESSION['uidno[0]']; I don't get any output at all.
Any help is appreciated.
thanks
Nicolas