Friday, October 31, 2008

AW: Delete Auth Cookie on Logout

Hi,

What I have:

function logout()
{
// Redirect users to this action if they click on a Logout button.
// All we need to do here is trash the session information:

$this->Session->delete('User');

// And we should probably forward them somewhere, too...

$this->redirect('/users/login');
}

So you can choose your favourite forwanrd and you should be happy.

Anja

-----Ursprüngliche Nachricht-----
Von: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] Im Auftrag von thatsgreat2345
Gesendet: Donnerstag, 30. Oktober 2008 21:25
An: CakePHP
Betreff: Re: Delete Auth Cookie on Logout


Not redirecting to the login page fixed it, I plan on sending it to the homepage after logout but the home page hasn't been created yet thus why i was just sending it back to the login page.

On Oct 30, 1:22 pm, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
> I have logout going back to the login page if this is the problem xD
>
> On Oct 30, 1:22 pm, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
>
> > When I do a pr of it , on logout it does a dump of all the data
> > still in the session.
>
> > Array
> > (
> >     [Config] => Array
> >         (
> >             [userAgent] => f221f8a145cf92f820aefa5fc4a585bb
> >             [time] => 1225399272
> >             [rand] => 1107590627
> >             [timeout] => 7
> >         )
>
> >     [Auth] => Array
> >         (
> >             [User] => Array
> >                 (
> >                     [id] => 1
> >                     [created] => 2008-10-29 14:43:47
> >                     [modified] => 2008-10-29 14:43:49
> >                     [username] => thatsgreat2345
> >                     [level] => 9
> >                     [email] => thatsgreat2...@gmail.com
> >                 )
>
> >         )
>
> >     [Message] => Array
> >         (
> >         )
>
> > )
>
> > On Oct 30, 12:56 pm, teknoid <teknoid.cake...@gmail.com> wrote:
>
> > > Auth doesn't set any cookies...
>
> > > logout() should handle deleting the session for you.
> > > try to pr($this->Session->read()); anywhere after logout and see
> > > what happens.
>
> > > maybe the problem is somewhere else
>
> > > On Oct 30, 3:13 pm, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
>
> > > > I have a users controller that when logs in redirects to another
> > > > controller that manages the redirects so if an admin logs in it
> > > > sends them to the admin controller and if a customer logs in it
> > > > sends them to the customers controller. They both have different
> > > > access levels, so when I logout I want the cookie deleted but I
> > > > can't seem to achieve it.
> > > > I have session in the components. Just wondering how I can get
> > > > the session to be deleted.
> > > > The problem arising is that when I logout and try to login as a
> > > > different user with a different level of access it throws an
> > > > authError but when I try to login with the same username and
> > > > access level it sends me to the right place.
>
> > > >   function logout() {
> > > >          // $this->Session->del('CAKEPHP');
> > > >           $this->Session->destroy();
> > > >           $this->Session->setFlash('You have logged out.');
> > > >           $this->redirect($this->Auth->logout());
> > > >   }


--~--~---------~--~----~------------~-------~--~----~
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 cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: