CakePHP: Components, redirect fail (On my part…)

I’ve been working on a CakePHP project lately and created a small component which was only needed in one of my controllers:

class CounterComponent extends Component {
  var $components = array(
    'Session'
  );

  function i() {
    if ($this->Session->check('Counter.i')) {
      $i = ($this->Session->read('Counter.i') + 1);

    } else {
      $i = 0;
    }

    $this->Session->write('Counter.i', $i);

    return $i;
  }

  function clear() {
    $this->Session->delete('Counter.i');
  }
}

Continue reading “CakePHP: Components, redirect fail (On my part…)”