Rust February 2016

Redirect to homnepage fails: header already sent

Hi whenever a user enters their details on my login screen, I end up with the following error:

Warning: Cannot modify header information - headers already sent by (output started at /customers/2/a/e/somedomain.co.uk/httpd.www/Francium/logSys/example-two-step-login/login.php:14) in /customers/2/a/e/somedmain.co.uk/httpd.www/Francium/logSys/class.logsys.php on line 448 Warning:

setcookie(
  "logSyslogin",
  hash("sha256", self::$config['keys']['cookie'] . $us_id . self::$config['keys']['cookie']),
  strtotime(self::$config['cookies']['expire']),
  self::$config['cookies']['path'], self::$config['cookies']['domain']
);

Cannot modify header information - headers already sent by (output started at /customers/2/a/e/somedomain.co.uk/httpd.www/Francium/logSys/example-two-step-login/login.php:14) in /customers/2/a/e/somedomain.co.uk/httpd.www/Francium/logSys/class.logsys.php on line 1060

public static function redirect($url, $status = 302){
  header("Location: $url", true, $status);
  exit(0);
}

Answers


Gwendal February 2016

This is caused by an output at line 14 if your login.php. If you echo something, php have to send headers in order for your browser to be able to display it. Once they are sent, you can't modify them

Post Status

Asked in February 2016
Viewed 3,440 times
Voted 7
Answered 1 times

Search




Leave an answer