title: Undefined method stdClass::user() error when using CakePHP Auth
body: <p>I'm fairly new to CakePHPand am building a site using the Auth component. A couple of times I have tried to do things with this component which have caused the error</p>
  
  <pre><code>Fatal error: Call to undefined method stdClass::user() in /ftphome/site/app/controllers/users_controller.php on line 395
  </code></pre>
  
  <p>The line it refers to in this case is</p>
  
  <pre><code>$this-&gt;User-&gt;read(null, $this-&gt;Auth-&gt;user('id'));
  </code></pre>
  
  <p>This error does not disappear when I revert the code back to how it was before the error and I only seem to be able to get rid of it by removing some files on the server (I'm not sure which files, when I tried removing all files in the <code>tmp</code> directory the error persisted so I removed the entire site and restored from the latest svn revesion.</p>
  
  <p>In this particular case I think I caused the error by putting the following code in <code>app_controller</code></p>
  
  <pre><code>class AppController extends Controller {
      function beforeRender() {
          $this-&gt;set('test', $this-&gt;Auth-&gt;user());
      }
  }
  </code></pre>
  
  <p>Which I copied from this thread <a href="http://groups.google.com/group/cake-php/browse_thread/thread/ee9456de93d2eece/cff6fe580d13622b?lnk=gst&amp;q=auth" rel="nofollow noreferrer">http://groups.google.com/group/cake-php/browse_thread/thread/ee9456de93d2eece/cff6fe580d13622b?lnk=gst&amp;q=auth</a></p>
  
  <p>A previous time I caused the issue by attempting to update the Auth user details after updating the user in the database.</p>
  
  <p>I can see I'm somehow removing the user object from the Auth object but I can't understand why I need to delete files in the site to get it back or how the code above removes it - any help would be much appreciated.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>It looks like in the case I mentioned above, the problem was the <code>app_controller.php</code> file which I'd copied into my <code>app/controllers</code> directory. Just having the file with an empty class declaration causes this error - can anyone provide further insight?</p>
  
  <p><strong>Further edit</strong></p>
  
  <p>I've realised I've been a bit silly and the problem was caused by me putting <code>app_controller.php</code> in <code>/app/controllers/app_controller.php</code> when there was already one in <code>/app/app_controller.php</code> - thanks for the input though Andy, it helps me understand a bit more what was happening.</p>