Monday, September 14, 2015

Re: Check user status fails

Try
if($status_user == 0 || empty($status_user) || $status_user = '')

On Thursday, August 13, 2015 at 3:37:31 AM UTC-5, Gerculy Robert wrote:
Hi, 
I'm trying to set some groups for user status :
0 - pending activation 
1 - user activated 
2 - temporary banned
3 - permanently banned  - not added in examaple 

My problem is no matter what I do, status 2 shows up

$status_user = $this->Session->read('Auth.User.status');
if($status_user == 0){
$this->Session->setFlash(__('You\'ve been logged out 0.'));
$this->redirect($this->Auth->logout());
} else if($status_user == 2){
$this->Session->setFlash(__('You\'ve been logged out 2.'));
$this->redirect($this->Auth->logout());
}else{
$this->Session->setFlash(__('Welcome '. $this->Auth->user('username')));
                        $this->redirect($this->Auth->redirectUrl());
//header('Location: dashboard');
}

I tried with switch case, same issue. It's been one hour running around without finding the problem,
I echo $status_user and surprise , it returned 1, which would redirect the user to dashboard.
If it's 0, returns, 0 if 1 or 2 returns 2 . 

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: