![]() |
Do I need to extend the session class? (Last visited url) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Do I need to extend the session class? (Last visited url) (/showthread.php?tid=28929) |
Do I need to extend the session class? (Last visited url) - El Forum - 03-25-2010 [eluser]tomdelonge[/eluser] So I made a little function so that when something is done, I can redirect the user to the last page. For example, maybe they added an item to their cart, I could give them a link that says, "back to search results" or "back to example product". I have a shopping library I'm making that just takes care of simple functions like add_to_cart and stuff. The library is autoloaded, and In the construct I run _history(). It seems to work fine. If I wanted to extend the session class, how would I do so? I know how to make MY_Session extends CI_Session or whatever, but how do I make it so this function runs everytime the session class does? (In other words, can I "extend" a function?) Do you recommend that? Or should I just leave it as is (It works). Code: function _history() Thanks. Do I need to extend the session class? (Last visited url) - El Forum - 03-25-2010 [eluser]stuffradio[/eluser] Why would you want to extend the session class? What benefit do you see from doing that? Do I need to extend the session class? (Last visited url) - El Forum - 03-26-2010 [eluser]tomdelonge[/eluser] I just figured it's useful and has to do with the user's session. I'd be able to use it in future projects more easily if I just extended the class. Should I just not worry about it? And copy and paste (or rewrite, since it's simple enough) into each project? I can do that I guess. Just wondered how I could extend the construct of the session class. Do I need to extend the session class? (Last visited url) - El Forum - 03-26-2010 [eluser]Raphael Passini[/eluser] tomdelonge, Make it by using hooks. Let me explain better: file: ../application/hooks/url_register.php Code: Class UrlRegister { file: application/config/hooks.php Code: $hook['post_controller'][] = array( |