title: access joomla session in php - codeigniter
body: <p>I need to check if the user is logged in or not in CodeIgniter.</p>
  
  <p>The login is happening in Joomla site.</p>
  
  <p>I tried the following to initialize joomla .</p>
  
  <pre><code>define( '_JEXEC', 1 );
  define( 'DS', DIRECTORY_SEPARATOR );
  define('JPATH_BASE', dirname(__FILE__) );
  
  require_once ("../includes/defines.php");
  require_once ("../includes/framework.php");
  
  $mainframe =&amp; JFactory::getApplication("site");
  $mainframe-&gt;initialise();
  
  $session =&amp; JFactory::getSession();
  $user = $session-&gt;get( 'user' );
  </code></pre>
  
  <p>But I got this message:</p>
  
  <blockquote>
    <p>No configuration file found and no installation code available.
    Exiting...</p>
  </blockquote>
  
  <p>Joomla is installed on root and codeigniter on root/advanced </p>
  
  <p>I am calling the code in controller.</p>
  
  <p>How can I solve this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Now I am getting this error:</p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Undefined variable: BM</p>
    
    <p>Filename: core/CodeIgniter.php</p>
    
    <p>Line Number: 364</p>
  </blockquote>
  
  <p><strong>Edit</strong></p>
  
  <p>My Controller look like this</p>
  
  <pre><code>function is_logged()
      {
  
                  define( '_JEXEC', 1 );
              define( 'JPATH_BASE', '../');
              define( 'DS', DIRECTORY_SEPARATOR );
  
          require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
          require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
          //require_once ("../libraries/joomla/user/authentication.php");
          $mainframe =&amp; JFactory::getApplication("site");
          $mainframe-&gt;initialise();
  
          $session =&amp; JFactory::getSession();
          $user = $session-&gt;get( 'user' );
  
  
  
      }
  </code></pre>
  
  <p><strong>Directory Structure</strong></p>
  
  <pre><code>--Public_html
    --Joomla Istallation files
    --Advanced [This is a folder ,i installed codeignitor on this folder]
  </code></pre>
  
  <p>So the path to joomla is <code>site.com/</code> and path to Codeignitor is <code>site.com/advanced</code></p>
  
  <p><strong>More about the Error</strong> </p>
  
  <p>Line 364 on Codeignitor Core says that :</p>
  
  <pre><code>// Mark a benchmark end point
      $BM-&gt;mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
  </code></pre>
  
  <p>and i can see the following on the starting of CI core</p>
  
  <pre><code>    $BM =&amp; load_class('Benchmark', 'core');
      $BM-&gt;mark('total_execution_time_start');
      $BM-&gt;mark('loading_time:_base_classes_start');
  </code></pre>