Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problems with before() and $this->response->redirect()
  • I'm trying to disallow user to sign-in or sign-up when he is already signed-in and vica versa. I have method that returns boolean of user's state. And then I have a controller that extends from template's controller and in it - before() method that should check for that state and, if it's true, redirect to main page. I can't get where's the problem...
    function before() {
    
      if ( Diesel::is_signedIn() !== null ) {
    
        $this->response->redirect( 'index' );
    
      }
    
    }
    

    And the error message... 19292-large.jpg
  • The before() method is used the the base Controller_Template, you need to call parent::before() in your new before() method.
  • Thanks, you're the best! Forgot that template's controller may use before() (and after(), and ..) as well. P.S. You can use Diesel::is_signedIn() instead of Diesel::is_signedIn() !== null.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion