<?php
include 'ProcessDAO.php';
$dest="";
if(isset($_POST['login'])){
    session_start(); // i get an error in this line !!
    $_SESSION['status']='online';
    $_SESSION['breadcrumb']='home';
    $pro = new ProcessDAO();
    $dest = $pro->LogIn($_POST['username'],$_POST['password']);
}else{
    session_start();
    $dest ="Location: ../index.php";
    session_destroy();
}
header($dest);
?>

guyss can you help me out because in my Login.PHP file when i login i always get this error .

** Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\IPMS\process\ProcessDAO.php:1) in C:\xampp\htdocs\IPMS\process\login.php on line 5**

Member Avatar
LastMitch

@syria718

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\IPMS\process\ProcessDAO.php:1) in C:\xampp\htdocs\IPMS\process\login.php on line 5

May I ask why you have 2 session_start() function?

The reason why you got that error because you have 2 session_start() function! There should be only 1 session_start() function per page.

Try to put your session_start() function on top of your code instead of being in the middle.

From this:

<?php
include 'ProcessDAO.php';
$dest="";
if(isset($_POST['login'])){
session_start(); // i get an error in this line !!
$_SESSION['status']='online';
$_SESSION['breadcrumb']='home';
$pro = new ProcessDAO();
$dest = $pro->LogIn($_POST['username'],$_POST['password']);
}else{
session_start();
$dest ="Location: ../index.php";
session_destroy();
}
header($dest);
?>

To this:

<?php
session_start();
include ("ProcessDAO.php");
$dest="";
if(isset($_POST['login'])){
$_SESSION['status']='online';
$_SESSION['breadcrumb']='home';
$pro = new ProcessDAO();
$dest = $pro->LogIn($_POST['username'],$_POST['password']);
}else{
$dest = 'location: ../index.php';
session_destroy();
}
header($dest);
?>

thanks for that i did not get the same error again .. but what i get was these error when i transfer the session_start(); on top of my code ..

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\IPMS\process\ProcessDAO.php:1) in C:\xampp\htdocs\IPMS\process\login.php on line 14

Member Avatar
LastMitch

@syria718

thanks for that i did not get the same error again .. but what i get was these error when i transfer the session_start(); on top of my code ..

Did you write this code?

The reason why you got that error because you have 2 header which you should have only 1 header.

Take out line 14:

header($dest);

But i'm using it to redirect to the main page ..

thanks a lot i finally fixed the bug ..

Open the file in Notepad++ and change the encoding to Encode UTF-8 without BOM