Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:35:20+00:00 2026-05-24T01:35:20+00:00

My application is set up to always redirect to a login screen. The login

  • 0

My application is set up to always redirect to a login screen. The login and logout redirects are driving me nuts though.

When I actually login, first it will redirect to the logout URL, then if I login a second time it will redirect to the home page correctly. Then when I log out, it redirects to the login URL and not the logout URL.

In the app_controller.php

public function beforeFilter() {
    $this->Auth->userModel = 'User';
    $this->Auth->loginAction = '/users/login';
    $this->Auth->loginRedirect = '/home';
    $this->Auth->logoutRedirect = '/users/login/1';
    $this->Auth->authError = 'You must be logged in to view this page.';
}

And in the users_controller.php

public function login($loggedout = false) {
    if ($this->Session->check('Message.auth')) {
        $this->Session->setFlash('Incorrect username or password.', 'default', array('class' => 'msg error'), 'auth');
    } elseif ($loggedout) {
         $this->Session->setFlash('You have been logged out.', 'default', array('class' => 'msg success'), 'auth');
    }
}

/**
 * Logout action
 */
public function logout() {
    $this->redirect($this->Auth->logout());
}

I have no idea what is going wrong. It seems like a pretty simple component to use. I am new to CakePHP by the way.

basically, login should redirect to /home, and logout should redirect to /users/login/1 so I can display the “you have been logged out” message above the login form again. That is literally all I need to do.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:35:22+00:00Added an answer on May 24, 2026 at 1:35 am

    I don’t have a ton of experience with the Auth component, but I suspect you’re making this a little more difficult than it should be. The documentation is clear that, by default, Auth will block access to all actions except login() and logout().

    I’d start by removing the userModel and loginAction declarations (you’re specifying the defaults anyway). Also, you can probably remove all of the code in login() (leave the empty function). You can display any error messages from the Auth compoment in your view—include this in your login.ctp:

    echo $this->Session->flash('auth');
    

    Note that the Auth component will generate messages like the ones you have in your code. It’s probably easier just to let it do its thing, and only override that behavior where you really need to.

    I would also (temporarily) remove the loginRedirect and logoutRedirect declarations and see if things behave as expected. (By default, logins will redirect back to whatever page you were trying to access before you logged in. Logouts will redirect to the login page, with a flash message indicating you’ve been logged out.) If you need to change the default behaviors, add them back one at a time and test.

    Basically, since you’re using the User model that Cake expects by default, you hardly need any configuration at all—which is one of the nice things about CakePHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Java application has multiple frames. Some of them are set to be always
So I have a XNA application set up. The camera is in first person
Is it possible in a Facebook application to set the Site URL to a
I'm starting a console application, but when I redirect the standard output I always
My first query is this: $sql = UPDATE application SET userid = ? WHERE
With this configuration cap deploy always hangs: set :application, myapp set :scm, :git set
- (void) applicationDidFinishLaunching:(UIApplication *)application { //set up main loop [NSTimer scheduledTimerWithTimeInterval:0.033 target:self selector:@selector(gameLoop:) userInfo:nil
This does NOT work: Sub X() Dim A As Access.Application Set A = CreateObject(Access.Application)
I have the update frequency of my ClickOnce application set to weekly. What is
Can the application use set same char in the XON and XOFF? If yes,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.