Monday, 24 July 2017

php - header location works in one file, but not in the other

I have this code as shown bellow:



session_start();
require_once 'classes/cookie.class.php';
if(!isset($_SESSION['logged']) && !Cookie::checkCookie($_COOKIE['smt_auth']))
{
header('Location: login.php');
exit;

}


?>



It's working right in localhost, as it redirects always to login.php if the user is not logged, neither has a cookie. But the problem comes when I try to put these files in the host, it stops working.



The two files using this are index.php and temario.php, when I try to introduce the url of index.php it redirects me to login.php but, in temario.php, the screen just gets blank and doesn't redirect.



Both files have the same PHP block (there are no white spaces as I copy&pasted from index.php to temario.php), so does somebody know why this could not be working in the host, but it does on localhost with xampp?




It's throwing the error:



Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /homepages/3/d507876316/htdocs/new/usuario/temario.php:1) in /homepages/3/d507876316/htdocs/new/usuario/temario.php on line 4


Also if I make a copy of index.php and rename it, it also works as intended.



Thanks in advance.

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...