Reputation: 647
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?
Upvotes: 1
Views: 994
Reputation: 66
"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.
Upvotes: 2