Community site: login faq

I built my first app with Cake, and everything went great until I uploaded it.

I have Cake, including the app folder, inside of a subdirectory of my root. I'm not sure if I needed to do anything else to configure the setup, or even if this has anything to do with the error.

On my local server, auth works fine and I'm able to login without issue. I uploaded the site to webfaction, though, and now when I log in, nothing happens, the page just reloads and if I debug auth, I can see that the form successfully submits to it the username and password, but I get no error messages from php, no "invalid password" error, the page just reloads.


I'm not even sure where to start looking to debug it. Any pointers?

asked 08 Apr '12, 22:34

adammpkins's gravatar image

accept rate: 0%

I see a large number of PHP warnings on this page - is that normal, and does it occur in your development environment as well?

Also, can you describe your development environment in detail? What type of server are you using to serve PHP, which PHP version, etc?

(08 Apr '12, 22:53) ryans ♦♦ ryans's gravatar image

I'm aware of the php warnings. They're occurring because it's in strict mode, though I assume that these are unrelated to the problem at hand.

I'm using xampp for windows as my development environment, therefore: Apache 2.2.21 MySQL 5.5.16 PHP 5.3.8

(09 Apr '12, 11:48) adammpkins adammpkins's gravatar image

I should mention that I even tried building the same Users class from scratch in a fresh cake install outside of a subdirectory (in the root), again using the tutorial at http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html. Doing this, I get the same results. The login just refreshes.

(09 Apr '12, 11:52) adammpkins adammpkins's gravatar image

I uploaded my code at: http://pastebin.com/dwBYWxMh

(09 Apr '12, 16:59) adammpkins adammpkins's gravatar image

We don't have much expertise with CakePHP here, so I'm brushing up on it before I attempt to troubleshoot this. Thanks for your patience :)

(09 Apr '12, 17:03) seanf ♦♦ seanf's gravatar image

Ok, I've narrowed this down to a PHP 5.4 problem.

I went through the entire blog and auth tutorials using PHP 5.4, and had the same problem as you. Everything works except for authentication, and my login form displayed the "Strict (2048): Declaration of User::beforeSave() should be compatible with Model::beforeSave($options = Array) [APP/Model/User.php, line 33]" errors.

I then took the same steps using a PHP 5.3 app, and had no problems - everything works, including authentication.

I think the strict mode errors might be significant in this case (contrary to earlier statements), mainly because E_STRICT isn't set in our environment, and setting error_reporting to E_ALL doesn't make the errors go away, which leads me to believe that there might be something buggy with Cake + PHP 5.4.

If you're set on using PHP 5.4, then try updating your code with whatever changes are needed to resolve the errors. I just checked in the #cakephp IRC channel on Freenode and was told "your APP/Model/User.php seems to only define beforeSave(), it wants beforeSave($options = array())". I changed my beforeSave function in Model/User.php to this...

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    return true;

... and that resolved the error and I was able to authenticate. Based on the errors I see on your site, you might need to update other parts of your code to get everything working.

If you're not set on PHP 5.4, then try using a PHP 5.3 app - based on my own tests, that should get you up and running.

Hope that helps!

permanent link
This answer is marked "community wiki".

answered 09 Apr '12, 19:05

seanf's gravatar image

seanf ♦♦
accept rate: 37%

edited 09 Apr '12, 19:45

I just tried this. Running it as a 5.3 app seemed to have gotten rid of the php warnings, but it's not taking care of the issues with login, and I'm also noticing that redirects don't appear to be working either.

For the redirects, I've allowed access to index methods so that I could demonstrate the issue, go to http://adammpkins.webfactional.com/users and add a new user, you will see that it does not redirect after the add.

As for the login, I set up a test user. Go to http://adammpkins.webfactional.com/users/login The test username is "test" and its password is test123. Try logging in and you will see, as before, that the page just refreshes still. Thanks for the help, I appreciate the troubleshooting as im at my wit's end.

(09 Apr '12, 20:46) adammpkins adammpkins's gravatar image

The JavaScript console shows a missing file for that page,


Since those deletes are using AJAX to send the call it is possible the redirect is defined within that file.

To troubleshoot any further we would need you to provide the paths on disk to the file that contains the code that controls this page. If you do not want to post it here you may submit a support ticket.

(09 Apr '12, 22:52) johns ♦♦ johns's gravatar image

/home/adammpkins/webapps/htdocs/app/Controller/UsersController.php /home/adammpkins/webapps/htdocs/app/Controller/AppController.php /home/adammpkins/webapps/htdocs/app/Model/User.php /home/adammpkins/webapps/htdocs/app/View/Users/login.ctp

Let me know if there's anything else I can provide.

(10 Apr '12, 10:19) adammpkins adammpkins's gravatar image

Sorry, I've looked but I've not been able to identify the problem.

Here's my working code, maybe you can compare it to yours and spot the difference.

(10 Apr '12, 18:50) seanf ♦♦ seanf's gravatar image

I plugged in your userscontroller and everything's working fine now. I'm checking out the differences to see what the issue was.

(10 Apr '12, 21:37) adammpkins adammpkins's gravatar image

Also, did you have to do anything to get the redirects working right? When I left they weren't working and when I came back, that issue was cleared up.

(10 Apr '12, 21:40) adammpkins adammpkins's gravatar image

No, I didn't do anything with your redirects - but I'm glad to hear that everything's working for you :)

(10 Apr '12, 22:08) seanf ♦♦ seanf's gravatar image
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 Apr '12, 22:34

question was seen: 9,049 times

last updated: 10 Apr '12, 22:11