title: issue in session variables
body: <p>I am new to php.<br>
  I want to use form data that are sent through <code>&lt;form method="POST" action="formdata.php"&gt;</code> to <em>formdata.php</em> be used in <strong>another</strong> file called <em>main.php.</em> For this I ucerated session variables in <em>formdata.php</em> </p>
  
  <p>Hers's my code in <strong>formdata.php</strong>  </p>
  
  <pre><code>&lt;?php
  session_start();   
  include_once("connect.php");
  
  $n=$_POST['name'];
  $p=$_POST['password'];
  $sql=mysql_query**strong text**("SELECT * FROM member WHERE `userName`='$n' AND `password`='$p'");
  
  if(mysql_num_rows($sql)==1){
      $_SESSION['user']=mysql_fetch_array(mysql_query("SELECT * FROM member WHERE `userName`='$n' AND `password`='$p'"));
  
  if($_SESSION['user']){ 
      $user=$_SESSION['user'];
  
      $_SESSION['userN']="$user(['userName'])";;
      $_SESSION['level']="$user(['level'])";
      //header("location:mainPage.php");
      echo $user['level'];
      echo $_SESSION['level'];
      }
  }
  
  else{
      echo "invalid user name or password" ;
  }
  
  
  
  ?&gt;  
  </code></pre>
  
  <p>But when I <code>echo $user['level'];
      echo $_SESSION['level'];</code> all I get printed is <code>3Array(['level'])</code>. Here <code>echo $user['level']</code> gives the desired out put 3, but <code>echo $_SESSION['level']</code> gives an array as <code>Array(['level'])</code>. What can I do to make it print <code>3</code>?<br>
  My next question is I want to use this level value in <strong>another</strong> php file (main.php). I lerant that session variables are global. So can I use <code>$user['level']</code> or should I use <code>$_SESSION['level']</code>.  In <strong>main.php</strong> I want to check the condition   </p>
  
  <pre><code>if($user['level'] == 3) {
      echo "level 3 user";
  
      }
  </code></pre>