CodeIgniter Forums
Helper File Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Helper File Error (/showthread.php?tid=47858)



Helper File Error - El Forum - 12-25-2011

[eluser]ibnclaudius[/eluser]
I got this error while trying to create a new helper, what can be?

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: CI

Filename: helpers/auth_helper.php

Line Number: 11
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: helpers/auth_helper.php

Line Number: 11

Fatal error: Call to a member function userdata() on a non-object in /home/brainflo/public_html/application/helpers/auth_helper.php on line 11

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function __construct() {

  $CI =& get_instance();

}

function is_logged() {
  
  if ($CI->session->userdata('logged_in')) {
  
   redirect('admin', 'refresh');
   die();
  
  }
  
}

function is_not_logged() {
  
  if (!$CI->session->userdata('logged_in')) {

   redirect('web', 'refresh');
   die();
  
  }

}

?>