title: What do I need to store in the php session when user logged in?
body: <p>Currently when user logged in, i created 2 sessions.</p>
  
  <pre><code>$_SESSION['logged_in'] = 1;
  $_SESSION['username']  = $username; // user's name
  </code></pre>
  
  <p>So that, those page which requires logged in, i just do this:</p>
  
  <pre><code>if(isset($_SESSION['logged_id'])){
  // Do whatever I want
  }
  </code></pre>
  
  <p>Is there any security loopholes? I mean, is it easy to hack my session? How does people hack session? and how do I prevent it??</p>
  
  <p>EDIT:</p>
  
  <p>Just found this:  </p>
  
  <p><a href="http://www.xrvel.com/post/353/programming/make-a-secure-session-login-script" rel="noreferrer">http://www.xrvel.com/post/353/programming/make-a-secure-session-login-script</a></p>
  
  <p><a href="http://net.tutsplus.com/tutorials/php/secure-your-forms-with-form-keys/" rel="noreferrer">http://net.tutsplus.com/tutorials/php/secure-your-forms-with-form-keys/</a></p>
  
  <p>Just found the links, are those methods good enough?? Please give your opinions. I still have not get the best answer yet.</p>