Passing Global Data MY_Controller Safe? |
I am using codeigniter MY_Controller to pass some global data so do not have to load it in every page.
The question I have: Is it safe to do so because I have never really done it before through MY_Controller passing data. I have all ways load data each time in to different controllers. PHP Code: <?php
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
the problem with your approach is, what are you doing with your data if you need them in one of your models ?
do you pass them through one of your controllers ?
The question of safety really depends on whether you have controllers which should not have access to the data but which extend this controller.
Additionally, you should make the method(s) protected instead of public, since CodeIgniter will make public methods routable if they don't start with an underscore. It may not matter in this particular instance, with the method simply setting a property in the controller, but if someone later changed it to return the data, it could potentially expose data to the outside world. A protected method will still be available to controllers which extend this controller, it just won't be available to other code (or via the URL).
I have added protected now is this correct?
PHP Code: <?php
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
You don't need the underscore at the beginning of the method name if it's protected, unless that's part of your project's coding style guidelines.
|
Welcome Guest, Not a member yet? Register Sign In |