How safe is it to use login data within a PHP session?
<p>For example, how safe would it be to do the following to log in the user: (<code>set_userdata</code> just sets the <code>$_SESSION</code> variable).</p>

<pre><code>$sess_array = array(
     'id' =&gt; $row-&gt;id,
     'username' =&gt; $row-&gt;username
   );
   $this-&gt;session-&gt;set_userdata('logged_in', $sess_array);
</code></pre>

<p>(from <a href="http://www.iluv2code.com/login-with-codeigniter-php.html" rel="nofollow">http://www.iluv2code.com/login-with-codeigniter-php.html</a>)</p>

<p>And to check whether that array has a valid ID and username on every page, to make sure the user is logged in? Does keeping the ID make it safer (if a regular user cannot find this ID)?</p>