![]() |
Extending Input library get_instance() problem - 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: Extending Input library get_instance() problem (/showthread.php?tid=29465) |
Extending Input library get_instance() problem - El Forum - 04-10-2010 [eluser]LoRdCoStE[/eluser] Hi, I want to extend the input library, so I make MY_Input.php under application/library In this class I need to use session, and I want my library to be compatible with both standard session and database session. So I need to use $ci->session but I can't get it work because I think that the function get_instance is not already there when my class is initialized so: Code: var ci; is not working. How can I do that? I need access to session (both normal and db) so no $_SESSION. If this is absolutely impossible there are problem if I use just one session var (directly) $_SESSION['my_var'] also if database session are enable? I mean does ci unset that var or just don't call session_start()? Thanks for your help. Extending Input library get_instance() problem - El Forum - 04-11-2010 [eluser]LoRdCoStE[/eluser] up Extending Input library get_instance() problem - El Forum - 04-11-2010 [eluser]Phil Sturgeon[/eluser] Depends where you are putting that code within the Input library. The Input library is called very early on in the instance (before CI_Base is called and get_instance() is defined) so it will fatal error if you call in in the constructor, or any method called by the instrustor (or early CI). Pastie up some more code. Extending Input library get_instance() problem - El Forum - 04-11-2010 [eluser]LoRdCoStE[/eluser] Thanks for you answer. What I'm trying to do is an automatic CSRF library. Here some example code (that don't work): Code: <?php Right now I have solved using $_SESSION, but I would like to find a difference soulutions, maybe extending one of the input library method wher get_instance() is available. Extending Input library get_instance() problem - El Forum - 04-11-2010 [eluser]n0xie[/eluser] It might be easier to just extend the Form_Validation library then the Input library if you want 'standard' csrf protection. Take a look here |