title: Retrieve Single User Data Using Session After He Logged In
body: <p>i am new to this field and this is the first time i am working with session, the question may seem very basic but would appreciate if someone could help me. Currently I have made a login and logout page using session and wish to display data of the particular user who has logged in. The user is redirected to retailer_login.php after they sign in, apart from login form there are 4 pages for the entire login and logout process. </p>
  
  <p>retailer_login.php, retailer_session.php, retailer_profile.php, retailer_logout.php</p>
  
  <p>Every page is working fine however i am able to display only single data column of the user from database but i wish to display the entire information that is stored about that specific user.</p>
  
  <p>DATABASE</p>
  
  <pre><code>    Id  name  email          password  country  city   state  occupation
      1   sam   sam@gmail.com  sam       XYZ      ZBC    QWE    student
  </code></pre>
  
  <p>retailer_login page</p>
  
  <pre><code>&lt;?php
  session_start(); // Starting Session
  
  if (isset($_POST['submit'])) {
      try {
          if (empty($_POST['email']) || empty($_POST['password'])) {
              throw new Exception("email or Password is invalid");
          } else {
              // Define $email and $password
              $email      = $_POST['email'];
              $password   = $_POST['password'];
              // To protect MySQL injection for Security purpose
             $email      = stripslashes($email);
             $password   = stripslashes($password);
             $mail      = mysql_real_escape_string($email);
             $password   = mysql_real_escape_string($password);
           //Etablishing Connection with Server by passing server_name, user_id and password as a parameter
            $connection = mysql_connect("abc.com", "abc", "abc");
            // Selecting Database
              $db= mysql_select_db("abc", $connection);
              // SQL query to fetch information of registerd users and finds user match.
              $query = mysql_query("select * from retailerregister where password='$password' AND email='$email'", $connection);
              $rows = mysql_num_rows($query);
  
              if ($rows != 1)
                  throw new Exception("email or Password is invalid");
  
              $_SESSION['login_user'] = $email; // Initializing Session
              header("location: retailer_profile.php"); // Redirecting To Other Page
              mysql_close($connection); // Closing Connection
          }
      }
      catch (Exception $e) {
          $_SESSION['login_error'] = $e-&gt;getMessage();
          header("Location: index.html");
      }
  }
  ?&gt;
  </code></pre>
  
  <p>retailer_profile page</p>
  
  <pre><code>&lt;?php
  include('retailer_session.php');
  ?&gt;
  
  &lt;!DOCTYPE&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;title&gt;Welcome to your homepage&lt;/title&gt;
  
          &lt;meta name="viewport" content="width=device-width", initial-scale=1.0"&gt;
          &lt;link href="css/bootstrap.min.css" rel="stylesheet" /&gt;
          &lt;link href="css/styles.css" rel="stylesheet" /&gt;
          &lt;link href="css/carousel.css" rel="stylesheet"&gt;
          &lt;link href="css/style.css" rel="stylesheet"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="profile"&gt;
      &lt;div class="navbar navbar-inverse navbar-static-top"&gt;
          &lt;div class="container"&gt;
              &lt;a href="#" class = "navbar-brand"&gt; &lt;id="welcome"&gt;Welcome : &lt;i&gt;&lt;?php echo $login_session; ?&gt;&lt;/i&gt; &lt;/a&gt;
  
                  &lt;button class = "navbar-toggle" data-toggle = "collapse" data-target = ".navHeaderCollapse"&gt;
                      &lt;span class = "icon-bar"&gt; &lt;/span&gt;
                      &lt;span class = "icon-bar"&gt; &lt;/span&gt;
                      &lt;span class = "icon-bar"&gt; &lt;/span&gt;
                  &lt;/button&gt;
  
              &lt;div class="collapse navbar-collapse navHeaderCollapse"&gt;
                  &lt;ul class = "nav navbar-nav navbar-right"&gt;
                      &lt;li class ="active"&gt; &lt;a href="retailer_profile.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt; &lt;a href="#"&gt;Profile&lt;/a&gt;&lt;/li&gt;
                      &lt;li class="dropdown"&gt;
                          &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;Property &lt;b class ="caret"&gt;&lt;/b&gt;&lt;/a&gt;
                              &lt;ul class="dropdown-menu"&gt;
                                  &lt;li&gt; &lt;a href="retailer_property_add.php"&gt;Add property&lt;/a&gt; &lt;/li&gt;
                                  &lt;li&gt; &lt;a href="#"&gt;View property&lt;/a&gt; &lt;/li&gt;
                              &lt;/ul&gt;   
                      &lt;/li&gt;   
                      &lt;li&gt; &lt;a href="retailer_logout.php"&gt;&lt;id="logout"&gt;Log Out&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/div&gt;    
      &lt;/div&gt;              
  &lt;/div&gt;
  
  &lt;div name="container"&gt;
  
  
  &lt;/div&gt;
  
  &lt;script src = "js/jquery-1.11.1.js"&gt; &lt;/script&gt;
  &lt;script src = "js/bootstrap.js"&gt; &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>retailer_logout page</p>
  
  <pre><code>    &lt;?php
      session_start();
      if(session_destroy()) // Destroying All Sessions
      {
      header("Location: index.html"); // Redirecting To Home Page
      }
      ?&gt;
  </code></pre>
  
  <p>retailer_session page</p>
  
  <pre><code>&lt;?php
  // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  $connection = mysql_connect("abc.com", "abc", "abc");
  // Selecting Database
  $db = mysql_select_db("abc", $connection);
  session_start();// Starting Session
  // Storing Session
  $user_check=$_SESSION['login_user'];
  // SQL Query To Fetch Complete Information Of User
  $ses_sql=mysql_query("select * from retailerregister where email='$user_check'", $connection);
  
  $row = mysql_fetch_assoc($ses_sql);
  $login_session =$row['email'];
  
  if(!isset($login_session)){
  mysql_close($connection); // Closing Connection
  header('Location: index.html'); // Redirecting To Home Page
  }
  ?&gt;
  </code></pre>
  
  <p>right now i am only able to use <code>$login_session</code> in order to display email on profile page. Can anyone please tell my how to display other data of the logged in user on the retailer_profile page through session</p>