Monday, December 17, 2012

users session delete, destroy ??


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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: