TraXXz
TraXXz

Reputation: 3

Kohana 3.2.0 | How can I add an automatical redirect after session expired?

How can I add an automatical redirect after session expired? I'm using Kohana 3.2.0 and the session is stored in a cookie.

Right now the URL is for example http://webpage.com/test/myController

When the session is expired and I click on a link then I get a ReflectionException and the URL is showing: http://webpage.com/test/test/myController

Hope you can give me a little hint for redirecting automatically after the session is expired :)

Upvotes: 0

Views: 1538

Answers (1)

Luwe
Luwe

Reputation: 3034

Any value you set in the current session will not be available anymore when the session is expired. So one way would be to set a value and put this in the before() method of your controller:

// In your Controller::before() method
if (Session::instance()->get('valid') === NULL)
{
  $this->request->redirect('somewhere');
}

// This goes somewhere after the session expiry check
Session::instance()->set('valid', TRUE);

Upvotes: 1

Related Questions