Thursday, November 27, 2008

Re: calling exit() after redirect STILL redirects

I have added this code to the login function:

$this->Session->del('Auth.redirect');

The assessment from David was correct. Auth was redirecting to the
past viewed page, except logged in :/
Deleting this key solved the problem.

Thanks for your help everyone!

On Nov 25, 9:02 am, mark_story <mark.st...@gmail.com> wrote:
> There is no $this->exit() function.  Perhaps you are thinking of $this->_stop()?  Also in 1.2 there is no need to manually call exit().  It
>
> is called automatically by redirect().
>
> Your redirect call seems suspect as well.  I would just use $this->redirect('/users/login');  Of course it is always better to use array
>
> urls.
>
> -Mark
>
> On Nov 24, 4:34 pm, _Z <Zmcar...@gmail.com> wrote:
>
> > Hello,
>
> > I am redirecting a user to a login page after they register for an
> > account. A message is displayed to login with their new credentials.
> > However when the form is submitted to login, they are instead
> > redirected back to the register view.
>
> > It would appear that code after the redirect() call is running, but I
> > call $this->exit() as instructed.
>
> > I am completely stuck on this one! :p
>
> > Sample code:
>
> > function register() {
> >         if (!empty($this->data)) {
>
> >                 #process the data from POST. Check to see if hashed
> > values match
> >                  if ($this->data['User']['password'] == $this->Auth-
>
> > >password($this->data['User']['password_confirm'])) {
>
> >                 #create a new object
> >                 $this->User->create();
>
> >                 #apply this new data
> >                 $this->User->save($this->data);
>
> >                 #these params in redirect will exit function
> >                 $this->Session->setFlash('Account created succesfully.
> > Please log in');
> >                 $this->redirect('/users/login', null, $status = true);
> >                 $this->exit();
> >                 }
>
> >                 else {
> >                 #if dont match flash on screen and redirect
> >                 #$this->flash('passwords need to match','/user/
> > register');
> >                 $this->Session->setFlash('passwords need to match');
>
> >                 }
> >         #empty data, this is fine.
> >         }
>
> > }

No comments: