CodeIgniter Forums

Full Version: Controller filter does not work in the default controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I created a controller filter that checks if the user is logged in, but it doesn't work in the default controller (Home.php in this case).

It also happens that it doesn't work in any index method unless you put it also without the asterisk('user/*', 'user/').

Thank you and I appreciate a reply.

This is how I got it:

// List filter aliases and any before/after uri patterns
// that they should run on, like:

//    'isLoggedIn' => ['before' => ['account/*', 'profiles/*']],
    public $filters = [
        'isLoggedIn' => ['before' => [ 'user/*'[font=Consolas,]'user/','home/*']],
[/font]
Hello, I had the same problem.
`user/*` means the filter to be applied on any other URIs after user/.

To include `user`, do the following:

`public $filters = [
'isLoggedIn' => ['before' => [ 'user*', 'home*']],
]`

Note, there is no forward-slash before the *.