![]() |
writing a library that uses other libraries - 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: writing a library that uses other libraries (/showthread.php?tid=43080) |
writing a library that uses other libraries - El Forum - 06-29-2011 [eluser]dadamssg[/eluser] I'm trying to write a library that holds a function that simply checks if the user is logged in or not and return true/false. I need to load the session library in my library. I referenced the session class like the user guide says but it still isn't being referenced right. I still have an error on the line i'm setting $username with. Any see what im doing wrong? loginclass.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); my relavent controller function Code: public function log() writing a library that uses other libraries - El Forum - 06-29-2011 [eluser]dadamssg[/eluser] fixed it. I wasn't using $CI when i was referencing my session variables *fixed* Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); writing a library that uses other libraries - El Forum - 06-29-2011 [eluser]C. Jiménez[/eluser] You can't call $this->session because it doesn't exist. You have referenced your CI objec in $CI : $CI->load->library('session'); so use $CI instead $this Code: class Loginclass { if you want to use your $CI object in more than one method I reccomend you to save it in a private var of your class and fill it with your referenced CI object on class's constructor. Hope it helps! |