title: CakePHP How to call a controller function from an external function
body: <p>I'm having trouble with <a href="https://stackoverflow.com/questions/14725481/cakephp-accessing-the-session-in-a-php-file-located-in-the-webroot">accessing the session in an external .php script located in webroot</a>.</p>
  
  <p>Thought I'd write a function getSession() in one of my controllers and try to call it in the .php file.</p>
  
  <p><strong>So in steps:</strong></p>
  
  <ol>
  <li>I have file.php</li>
  <li>In a controller I have a function getSession().</li>
  <li>How to call the controllers function in the file.php?</li>
  </ol>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Meanwhile I fixed my bug, but still am curious how this is done and want other stack users to find a good answer to this so:</p>
  
  <p>Its exactly like this:</p>
  
  <p>In UsersController I have a function:</p>
  
  <pre><code>public function getSession() {
      return $_SESSION['Auth']['User']['user_id'];
  }
  </code></pre>
  
  <p>That I want to let's say print (for example) like this: print_r(Users.getSession) in the file test.php located in webroot/uploadify/test.php.</p>
  
  <p>This file is not a class, but if it is required, then it shall be :)</p>
  
  <p>@CaboOne: Maybe your answer was correct, I just wasnt sure what code to call (and enter) where :)</p>