I have spent the past 24 hours pulling my hair out over a very odd error in a CakePHP application I have been developing.
I had an app called training, so my directory structure looked like this (the training app was generated using bake)
I had copied large amounts of code from another cake site that I am also developing including a simple login system to password protect the admin routes.
I noticed that as I was browsing the site and tried to login, I would login successfully into the admin area and then as soon as I tried to access any controller method in the admin section I would be logged out.
I echoed all my POST and SESSION variables to the screen in the layout using:
So I knew that I was being logged in successfully.
When I tried to access another controller action e.g. /admin/courses/index I would be logged out and asked to login again. Eventually I noticed that when I logged in I was being redirected to /training/admin/homes/index instead of the expected /admin/homes/index which is why I was being logged out.
I examined all the releveant files in my working application and my broken one and discovered that the only difference was that the working application was called /app/ and the broken one was called /training/ I re-named training to /app/ uploaded the site and it all worked again.
I am not sure at the moment whether this is the result of something I have misunderstood or if it is a bug, anyway I’ll stick it on trac when I get the chance.