0

I'm working on an application (using Codeigniter framework) which needs an external php script to run separately. I want to access the Codeigniter object like this in that external file:

$CI =&get_instance();

the external file is placed in application/helpers/script.php

I followed This Solution but it didn't work for me.

also I tried this solution:-

ob_start();
include('index.php');
ob_end_clean();
$CI =& get_instance();
$CI->load->library('session'); //if it's not autoloaded in your CI setup
echo $CI->session->userdata('name');

but it generates errors like "Constant" already defined.

How can I access the Codeigniter object in the external file?

Vickel
  • 7,879
  • 6
  • 35
  • 56
RashFlash
  • 992
  • 2
  • 20
  • 40
  • If it's codeigniter that needs your external script and not the opposite, have you considered writing a CI library ? – AdrienXL Feb 22 '15 at 17:32
  • Actually, its the "External script" that need to use Codeigniter. – RashFlash Feb 22 '15 at 17:34
  • Did you find a solution? I also have a script (placed in the root folder, alongside CI's index.php) and I need it to access CI methods. – Mr Pablo Mar 17 '15 at 14:58
  • no sorry :( , What i did i make a separate folder in Codeignitor and create a separate logic for it. – RashFlash Mar 18 '15 at 04:05

0 Answers0