Using set before rendering a different page

Permalink
Could anyone point me in the right direction here please?

class MySinglePage extends PageController {
  public function view($var=null){
    if(is_null($var)){
      $this->set('error','I am sending this error to the login page/view.'); 
      $this->render('/login');
    }
  }
}
}


And the $error variable is not set

mikemiller