CodeIgniter Forums
Hook not running - 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: Hook not running (/showthread.php?tid=25755)



Hook not running - El Forum - 12-23-2009

[eluser]frist44[/eluser]
I'm trying to get a session variable written after the controller runs each time to set the 'prev_url' string, so that i can direct people back where they need to go after a post and things like that.

I thought a post_controller hook might be the way to go, so all my processing would take correct Previous URL string, and then once it's done, it'll update session: 'prev_url'.

For some reason my hook is not running though. I get a blank string in my session.

I enabled hooks in the config. Added this to the hook config file:

Code:
$hook['post_controller'][] = array(
                                'class'    => 'Test_hooks',
                                'function' => 'post_controller',
                                'filename' => 'Test_hooks.php',
                                'filepath' => 'hooks',
                                'params'   => array()
                                );

And this is the hooks file in the hooks folder with application:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test_hooks {


    function __construct()
    {
    }

    function post_controller()
    {
        $this->_CI =& get_instance();
        $this->_CI->session->set_userdata('prev_url', $this->_CI->uri->uri_string());
    }


}

Any ideas? or maybe a better way to process previous url?