Plus, the problem I ran into with this solution is that the logout
function goes into an infinite loop.

I will note that I didn't have problems with redirect until I started
using database sessions & stopped using mod_rewrite because of
restrictions on the shared server I'm using.

On Jul 15, 8:50 am, jhicks <[EMAIL PROTECTED]> wrote:
> That will only work as long as the browser supports HTTP_REFERER.
>
> On Jul 6, 2:52 pm, Chez17 <[EMAIL PROTECTED]> wrote:
>
> > Using Eric's post, I created a very simple way to get the Auth
> > component toredirectto the referring page no matter what. I think
> > its userful:
>
> > <?php
> > class UsersController extends AppController
> > {
> >     var $name = "Users";
>
> >     var $components = array("Auth");
>
> >     function beforeFilter()
> >     {
> >         $this->Auth->autoRedirect = false;
> >     }
>
> >     function login()
> >     {
> >         $this->redirect($_SERVER['HTTP_REFERER']);
> >     }
>
> > }
>
> > On Jul 2, 1:56 pm, Rich <[EMAIL PROTECTED]> wrote:
>
> > > that worked perfectly for me. thanks Eric!
>
> > > On Jul 2, 12:32 pm, Eric <[EMAIL PROTECTED]> wrote:
>
> > > > I had a similar problem and here is what I did.
>
> > > > 1. Change your setupAuth function like this
> > > > function setupAuth(  )
> > > > {
> > > > ...
> > > > $this->Auth->loginRedirect = '/users/loginRedirect';
> > > > $this->Auth->autoRedirect = false; // <-- handle redirecting yourself
>
> > > > }
>
> > > > 2. create a loginRedirect action which determines where to go after a
> > > > login has succeeded
>
> > > > function loginRedirect()
> > > > {
> > > >  $this->log('users/LoginRedirect()', LOG_DEBUG);
> > > >  if (parent::getAuthGroup() ===  "ADMIN")
> > > >  {
> > > >   $this->log('--redirecting to admin', LOG_DEBUG);
> > > >   $this->redirect('/admin/myCtrl/index');
> > > >  }
> > > >  else
> > > >  {
> > > >   $this->log('--redirecting to normal', LOG_DEBUG);
> > > >   $this->redirect('/myCtrl/index');
>
> > > > }
>
> > > > 3. Your login action is pretty simple then
>
> > > > function login()
> > > > {
> > > >  if ($this->Auth->login())
> > > >  {
> > > >    $this->loginRedirect();
> > > >  }
> > > >  else
> > > >  {
> > > >   if (!empty($this->data))
> > > >     $this->Session->setFlash($this->Auth->loginError);
> > > >  }
>
> > > > }
>
> > > > I think you can get the page that the user was trying to access via
> > > > the session, andredirectthere, but taking them to the front page
> > > > works for me
> > > > .
> > > > Hopefully this helps.
>
> > > > -Eric
>
> > > > On Jul 2, 10:44 am, leo <[EMAIL PROTECTED]> wrote:
>
> > > > > On 2 Jul, 17:27, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
>
> > > > > > I see what you mean, but I'm not sure that you can put 'action' => 
> > > > > > '/'
> > > > > > or 'controller' => '/'.
>
> > > > > Sorry, I missed that. Nope, I wouldn't want to be doing that even if
> > > > > it was valid.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to