User library issue, calling CI Library (session)

I created my own library and I'm trying to access information in my session, but I getting the following error. What am I doing wrong? (PHP5/MYSQL5(WAMP5:1.7.3), CI:1.6.1)):

<p>Severity: Notice</p>
<p>Message:  Undefined variable: CI</p>
<p>Filename: libraries/Podclass.php</p>
<p>Line Number: 20</p>

&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Podclass {
     * Constructor
    function Podclass()
        $CI =& get_instance();
    function lerror()
        $errors = array(0=>' ',1=>
            "<DIV class='error'> Invalid UserID/Password </DIV>",2=>
            "<DIV class='error'> You don't have access to this pod.</DIV>");
            return $errors[$CI->session->userdata('lerror')];

// END podclass Class

Thanks, in advance.

[eluser]Michael Wales[/eluser]
Scope. Your variable $CI is only available to the Podclass() function. Make it a class variable, like so:

class Podclass {
  var $CI;

  function Podclass() {
    $this->CI =& get_instance();

  function lerror() {
    return $this->CI->session->userdata('lerror');

Thanks, that worked!!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.