Redirection Error

from the distance it‘s for me very hard to help.
did you start a clean new cakephp project and follow the tutorial or do you copy and paste code from different sources in an existing project?

I had a cakephp project written in version 2 and I copied and pasted it into a new project. I used the tutorial a little bit.

I changed all of the code to work with version 4.

I cleared my cookies and tried return $this->redirect($this->referer()); again and this time the login page loaded but when it tried to redirect me I got the too many redirects error again.

The referring page is mealplans/index so I commented out all of my code in the index method of MealplansController and deleted the content of my index.php template but the page still didn’t load.

redirect to referer() called in login method will redirect you to the login page. you should redirect to an specific controller and action.

the other thing to mention is, that you spent a lot of time with copying code from different sources to your cakephp2 project without knowing if that will work.

you should start a clean new project, connect it to your database and then bake all elements. then it is easier to help you. at the moment it seems to me, that you have a mess in your code, that no one will ever understand.
my offer to you: describe what you want to achieve with your project, then we look over your database and relations and then you can bake all elements. after that you have a base of clean code and can ask for things that you don‘t understand.

When I add the following echo to my method:

echo $_SERVER['HTTP_REFERER'];

it returns

http://localhost/users/login?redirect=%2Fmealplans%2Findex

I baked the MealplansController so it should work.

I got it to work with return $this->redirect($this->Auth->redirectUrl());

It’s not redirecting any more. The url displays http://localhost/users/login?redirect=%2Fmealplans%2Findex and it never goes there!

Did you write that original CakePHP 2 application? From your posts here there are fundamental design issues being ignored and not understood. You seem to be developing by brute force. If this is for a commercial product (ie. someone is paying you to do this, you intend to sell it, you intend to charge customers for the use of it) - I urge you to use a support group like http://friendsofcake.com/ which may require you hiring someone.

I am all for you learning for yourself, but if this is to earn you money then protect yourself by ensuring your product is of the highest standard - that way you won’t get sued or lose all professional credibility when someone hacks your site, or you leak confidential information.

I know it’s stupid to have the confirm password field not hashed in the database but I am just experimenting with it while I’m still using dummy users. This is for a personal website not a paid gig.

You don’t need to have the confirm password field in the database at all. The password field needs to be hashed.

I replaced my login method with code that I found and now I don’t get the redirection error but now when I navigate to mealplans/index and mealplans/add I get a blank page.

I replaced my index.php template with a blank page that just said “test” but it didn’t print out “test,” it was completely blank.

I commented out all of the code in my MealplansController index method but it still renders a blank page.

Some of the other pages work. It’s just these two that don’t work.

I found the problem. My routes configuration was wrong

Blank pages are almost always a result of 500 server errors. If you have debug turned on, you’ll get useful output to help you find them instead of just the blank page. If you don’t have debug turned on, you should be able to find details in the Cake error log.