Do I need to extend the session class? (Last visited url) |
[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.
[eluser]stuffradio[/eluser]
Why would you want to extend the session class? What benefit do you see from doing that?
[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.
[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( |
Welcome Guest, Not a member yet? Register Sign In |