I suppose you'd have in session the user id.

Why not check if the user exists in the database or is enabled?

Maybe you don't want to do it in any request doing it one time each four
for example, or if you don't have a lot of traffic do it always before
doing any action.

BeforeFilter can help you with this.

http://book.cakephp.org/2.0/en/controllers.html

Regards,


-- 
Jorge González

Web Developer
twitter: @jorgonor
website: http://jorgonor.blogspot.com.es
github: https://github.com/jorgonor


2012/12/17 Chris <[email protected]>

>
> hi guys,...
> I'm building administration feature to manage users,... delete,
> deactivate,... etc,...
> Me, as admin, would like to delete some user and have him/here kicked out
> from logged in page,...
> so next thing he clicks anywhere on a site he will be logged off.
>
> I can't delete user session,... the function is deleting user, but it
> delete my session and not user.
> Destroying session$this->Session->destroy(); is not an option,...
> since it will destroy ALL users session while some uploading photos or
> creating blogs, groups, videos,... etc,...
> How can I do this,... ? Can someone help please,...
>
> here is my function:
>
>   function admin_delete($id = null)
>   {
>     if(!$this->authorize_admin())
>       return;
>
>     if(!($user = $this->User->findById($id)))
>     {
>       $this->flash('error', ucfirst(i18n::translate('user not found')));
>       $this->redirect('/admin/users/manage/');
>     }
>     else
>     {
>       if($this->User->delete($user['User']['id']))
>       {
>    // $this->Session->delete('user'); // This deleting my session,... not
> the user session
>    // $this->Cookie->delete('User.username');
>    // $this->Cookie->delete('User.hashed_password');
>
>    // $this->Session->destroy(); // This is destroying ALL users session,
> which I don't want to
>
>    $this->Session->delete($user['User']['id']); // Here is the part where
> I want to delete user sission
>    $this->Cookie->delete($user['User']['username']);
>    $this->Cookie->delete($user['User']['hashed_password']);
>
>         $this->flash('valid', ucfirst(i18n::translate('account deleted')));
>         $this->redirect('/admin/users/manage/');
>       }
>
>      }
>
>   }
>
>
> Thanks in advance
> chris
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to