Iluvatar+ Posted February 7, 2012 Share Posted February 7, 2012 I am have build an auth controller in cakephp but for some reason when i try and redirect the once the user is authenticated it only allows access actions within that controller. I have tried to redirect it to another controller which which is what i want the user to authenticate them selfs for, but all i get in a blank screen. :S. <?php class UsersController extends AppController { var $name = "Users"; var $layout = "login"; var $helpers = array('Html', 'Form'); function index() { } function beforeFilter() { $this->__validateLoginStatus(); } function login() { if(empty($this->data) == false) { if(($user = $this->User->validateLogin($this->data['User'])) == true) { $this->Session->write('User', $user); $this->Session->setFlash('You\'ve successfully logged in.'); } else { $this->Session->setFlash('Sorry, the information you\'ve entered is incorrect.'); } } } function logout() { $this->Session->destroy('user'); $this->Session->setFlash('You\'ve successfully logged out.'); $this->redirect('login'); } function __validateLoginStatus() { if($this->action != 'login' && $this->action != 'logout') { if($this->Session->check('User') == false) { $this->redirect('login'); $this->Session->setFlash('The URL you\'ve followed requires you login.'); } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/256615-redirect-to-another-controller-with-sessions/ Share on other sites More sharing options...
JacobCMarshall Posted February 8, 2012 Share Posted February 8, 2012 Sorry to ask, but what framework are you using? Quote Link to comment https://forums.phpfreaks.com/topic/256615-redirect-to-another-controller-with-sessions/#findComment-1315907 Share on other sites More sharing options...
Iluvatar+ Posted February 9, 2012 Author Share Posted February 9, 2012 cakephp Quote Link to comment https://forums.phpfreaks.com/topic/256615-redirect-to-another-controller-with-sessions/#findComment-1316068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.