![]() |
help creating a variable for logged in state that I can use in every controller and method site wide - 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: help creating a variable for logged in state that I can use in every controller and method site wide (/showthread.php?tid=29299) |
help creating a variable for logged in state that I can use in every controller and method site wide - El Forum - 04-05-2010 [eluser]Flying Fish[/eluser] I want to create a boolean $logged_in variable that I can user throughout my whole site, particularly in my controller methods So far, I'm extending the controller with MY_Controller and trying to define it there in the constructor function, but I'm getting a php error when trying to user $logged_in my controller methods, and not sure why any help would be appreciated Here's what MY_Controller looks like Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); and here's where the error is coming from Code: class Account extends MY_Controller{ Code: A PHP Error was encountered help creating a variable for logged in state that I can use in every controller and method site wide - El Forum - 04-05-2010 [eluser]Kamarg[/eluser] You need to do $this->logged_in or it will go out of scope when the function you use it in returns. help creating a variable for logged in state that I can use in every controller and method site wide - El Forum - 04-05-2010 [eluser]Flying Fish[/eluser] ok, would I do that in the controller method or when defining $logged_in help creating a variable for logged in state that I can use in every controller and method site wide - El Forum - 04-05-2010 [eluser]Kamarg[/eluser] All the places you use $logged_in need to be replaced with $this->logged_in. help creating a variable for logged in state that I can use in every controller and method site wide - El Forum - 04-05-2010 [eluser]Flying Fish[/eluser] I see, thanks |