0
I have a system that works perfectly on the computer(A) that was developed and, when passing to the computer(B) server with the same settings, the same version of Easyphp and etc, presented many, but many errors.
One of these errors is right in the login and says:
"Notice: A Session had already been Started - ignoring session_start() in (directory/logica-user.php) on line 4."
This is the logica-user.php:
<?php
session_start();
function verificausuario(){
if (!isset($_SESSION["usuario_logado"])) {
header("location: login.php");
die();
}
}
function verificausuario() {
if(!isset($_SESSION["usuario_logado"])) {
header("location: login2.php");
die();
}
}
function logaUsuario($nome) {
$_SESSION["usuario_logado"] = $nome;
}
function logout() {
session_destroy();
}
?>
Line 4 is this session_start(); but there is nothing wrong with it, after all, it is this whole bugged system is the same system that runs perfectly on the computer(A) and ran on the computer(B) before it is formatted.
This page must be included in another 2 or more times... usually this error comes from using include / require try to replace them respectively to include_once / require_once
– Guilherme Biancardi
Maybe you included in the document another page that had already given a
session_start
, thePHP
triggers this warning to alert you, if you want to fix this, review the logic and get them out of where you don’t need them, ultimately put a @ in front of thesession_start
to hide the Warning.– Felipe Duarte