Forum

Thread tagged as: Question, Problem, Members

Members Re-direct after logging in from registration.php

If a user registers to my site and then wants to login in immediately. The chances are that they'l use the login form that's been included in registration page

By default this simply logs them in and keeps them on registration with a custom message letting them know that they are already logged in. This is OK but I'd prefer it if it re-directed them to the members index.php page. I have tried doing this using an if members logged in then re-direct to this page statement. but it's giving me an error telling me the headers have already been sent.

Any ideas?

Richy Thomas

Richy Thomas 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need to do your redirect before outputting anything, even white space, to the page.

Even before including perch/runtime.php?

Drew McLellan

Drew McLellan 2638 points
Perch Support

The runtime doesn't output anything to the page.

A redirect is an HTTP header. So in order to set that header you need to have not started outputting the response body.