title: PHP Object 'user' goes away after refresh despite session continuing
body: <p>New at PHP, following various OOP tutorials, ran into something I don't know how to fix.
  Home.php</p>
  
  <pre><code>    &lt;?php
          //echo '&lt;img src="'.'uploads/photo.jpg'.'"alt="aaaaaa" style="width:256px;height:128px"&gt;';
          include_once "classes.php";
          $_SESSION['UserProfilePicture']=$user-&gt;getUserProfilePicture();//Dodging errors
          echo '&lt;img src="'.$_SESSION['UserProfilePicture'].'"id="HOMEPROFILE" alt="No Profile Found" style="width:128px;height:128px"&gt;&lt;br&gt;';
      ?&gt;
  </code></pre>
  
  <p>UserLogin.php</p>
  
  <pre><code>&lt;?php
      include_once "classes.php";
      if(!isset($_SESSION)){
          session_start(); //This is necessary above every file that uses session variables!
      }
      if(isset($_POST['UserMailLogin']) &amp;&amp; isset($_POST['UserPasswordLogin'])){//Grab by name
          $user = new user(); //Adds an object
          $user-&gt;setUserMail($_POST['UserMailLogin']);
          $user-&gt;setUserPassword(sha1($_POST['UserPasswordLogin']));
          if($user-&gt;validlogin()==true){
              $_SESSION['UserName']=$user-&gt;getUserName();//Use -&gt; when left is object, :: otherwise, =&gt; to assign key-value pairs in assoc array
              $_SESSION['UserMail']=$user-&gt;getUserMail();
              $_SESSION['UserId']=$user-&gt;getUserId();
              $_SESSION['Age']=$user-&gt;getUserAge();
              $_SESSION['UserLocation']=$user-&gt;getUserLocation();
              $_SESSION['UserProfilePicture']=$user-&gt;getUserProfilePicture();
          }
      }
  ?&gt;
  </code></pre>
  
  <p>I have created a simple login system that starts the session. When a new $user object is made in the class called users, I have set/get functions that supply the object with its proper values. Meanwhile, the $_SESSION superglobal variables are also set. It takes them to the Homepage. On Home.php, I want to access $user->getUserProfilePicture(), which works, but upon refresh it can't seem to find the object $user. I've tried getting around this with using $_SESSION instead but that only delays the problem in the event that later I want to display other person's profile pictures and if I log out and log back in and refresh then it still has the same problem. Please help me find a way to keep the object $user. Thanks in advance.</p>
  
  <p>EDIT:
  Sorry guys I tried to cutout the nonessential stuff but I do have if(!isset($_SESSION))session_start(); at the start of every page</p>