• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
passing the same variables to all the views (to handle login status)


I want to show in each page (almost each page) a login or logout link like the one in this forum.

I'm organizing my views through django like inherited templates and I'm using dx_auth as authentication library.

How I can accomplish that?
I can for example pass each time a variable data["is_logged"] = True, though it leads to a big code duplication, what's the best solution you've found?

Create a "secure controller" that extends the base controller, and in the constructor do your if($logged){} check. Then, any controller in which all the methods need to be secured, you will inherit the secure controller instead of the base controller. Make sense?


or google codeigniter MY_Controller

You can 'give' variables to all views using $this->load->vars($array);
// set variables
$this->load->vars('name'=>'Pete', 'profilelink'=>site_url('profile/pete'));
// now you can use $name and $profilelink in any view.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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