1

I want to add functionality to check session ao. I created one function like checkSession in my app_controller. Now, the first time the application loads it redirects to the admin/users/login page.

At this login form, if I insert correct data then it redirects to my applications home page. I have user admin prefixed in my application.so after successfull login I want to redirect to localhost/appName/admin so I wrote the below code:

$this->redirect(Router::url("/admin",true));

It works fine in local but when I upload it on server it shows me error like

Warning (2): Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/pms/app/controllers/users_controller.php:192)

The code on 192 line is

$this->redirect(Router::url("/admin",true));

Can you suggest me its alternative option?

1 Answer 1

2

"Warning (2): Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/pms/app/controllers/users_controller.php:192)"

The "headers already sent by" message occurs when you print something and then try to set a header, like the Location header used for redirection. Just make sure you're not sending anything to the browser (printing) before calling the $this->redirect method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.