Problem when using header () function in php

0

Good morning, colleagues!

I have a problem using header () in php, I tell you I am using mvc natively and the dashboard of my app I use it in the construct of my template class and it is called from the index therefore it is always invoked!

The thing is that I'm using header ("Location: '. URL.'Login.php"); for when the session is destroyed and redirect to the login but I get this error!

Warning : Can not modify header information - headers already sent by (output started at /opt/lampp/htdocs/Centralapp/Views/Template/Template.php:75) in / opt /lampp/htdocs/Centralapp/Controller/PrincipalController.php on line 46

Warning : require (/ opt / lampp / htdocs / Centralapp / Views / Principal / Logout.php): failed to open stream: The file or directory does not exist in /opt/lampp/htdocs/Centralapp/config/Enrutador.php on line 28

Fatal error : require (): Failed opening required '/opt/lampp/htdocs/Centralapp/Views/Principal/Logout.php' (include_path = ' .: / opt / lampp / lib / php ') in /opt/lampp/htdocs/Centralapp/config/Router.php on line 28

The last two errors is because it does not find the file but it does not exist since it is a function of the controller! the first error is the one that causes me problems!

the code of my index is the following:

<?php
 session_start();
 define('DS', DIRECTORY_SEPARATOR);
 define('ROOT', realpath(dirname(__FILE__)).DS);
 define('URL', 'http://localhost/Centralapp/');
 require_once "config/Autoload.php";

 if(@$_SESSION['InicioSesion'] == 'Si') {

 config\Autoload::run();
 require_once 'Views/Template/Template.php';
 config\Enrutador::run(new config\Request());
 }else{

 config\Autoload::run();
 require_once 'Login.php';
 config\Enrutador::run(new config\Request());

 }

the code of the controller function is as follows

 public function Logout(){
    session_destroy();
    header('Location:'.URL.'Login.php');

}

Call that function because in the dashboard template I have a button to exit the session and in that link I call the logout method which is the one that ends the session.

I hope to have explained myself well! And thank you in advance greetings

    
asked by Pablo Moraga 11.12.2017 в 05:52
source

0 answers