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 3945722
In Process

The Archive Base Latest Questions

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

I would like to get rid of Auth component error messages, specially the authError

  • 0

I would like to get rid of Auth component error messages, specially the authError message that comes whenever I try to access a non-allowed action.

Just to be sure, I double check that there is no $this->Session->flash() call anywhere in the layout. Besides, setting an empty value does not work, as the component has a default message value.

I am using the Auth component with the following configuration in AppController class:

class AppController extends Controller {
    var $components = array(
        'Auth' => array(
            'userModel' => 'WebUser',
            'loginAction' => '/login',
            'loginRedirect' => '/',
            'logoutRedirect' => '/login',
            'autoRedirect' => false,
        ),
        'Session',
        ...
     ...
}

For login and logout redirections I have setup two routes:

Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
Router::connect('/login', array('controller' => 'web_users', 'action' => 'login'));

The login action within WebUser controller is almost empty; I only change the default layout:

function login() {
    $this->layout = 'login';
    $this->set('title_for_layout', 'Sign in');
}

Finally, I have a very simple login.ctp layout file:

<html>
    <head>
        ...
    </head>
    <body>
        ...
        <?php echo $content_for_layout; ?>
        ...
    </body>
</html>

When I access http://example.com/login there is no problem, no messages, just the login form. However I get the default authError message when requesting any other action, just after the Auth component redirects to the login action. Two questions arise:

  1. Why is the Auth component displaying flash messages when there is no $this->Session->flash() call anywhere? (see update 2 below)
  2. How can I setup an empty/null value in authError attribute?

Thanks!

UPDATE

I came up with a really ugly solution: I created an element login_error.ctp and assigned to the flashElement attribute in Auth component initialization:

class AppController extends Controller {
    var $components = array(
        'Auth' => array(
            'flashElement' => 'login_error',
        ...
     ...
}

In login_error.ctp I just compare with the authError default message:

<?php if ( $message !== 'You are not authorized to access that location.' ): ?>
<div id="flashMessage" class="message"><?php echo $message; ?></div>
<?php endif; ?>

It works, but I hate it!

UPDATE 2

Thanks to dogmatic69 answer I forced myself to check everything again. I finally found where the call to $this->Session->flash() was being made. It was on a little view element that I had wrote before. It had nothing to do with login/logout stuff so I did not pay attention to that file.

UPDATE 3

Thanks to SpawnCxy answer as well. Copying the Auth component and making custom modifications is a better approach than string comparison.

  • 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-20T01:02:57+00:00Added an answer on May 20, 2026 at 1:02 am

    just remove $this->Session->flash('auth') from your view/layout.

    http://book.cakephp.org/view/1467/flash

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

Sidebar

Related Questions

On the site: ukrainiansecret.com I would like to get rid of that green right
I would like to get rid of the close/X button on the top right
In a UITextField used for entering decimal numbers I would like to get rid
I would like to get View instance that is used to display specific Preference
How do I get rid of the whitespace in my application: I would like
I would like to get rid of all the file extensions on my site.
I would like to get rid of the search of id's of certain column
My question is already specified in the title: I would like to get rid
I have a java string of form a_x,b_y,c_z. I would like to get rid
On an embedded file system, I would like to get rid of libthread_db. My

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.