Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    1

    Unanswered: Cannot send session cache limiter - headers already sent Error

    Hi guys

    I have been receiving this error for a while was wondering if anyone would be so kind to assist me in solving this problem.

    Script below:

    <? session_start();?>
    <?php
    require_once('includes/authenticate.class.php');
    $auth = new Authenticate();
    $OppLogin_txtEmail=$_REQUEST['OppLogin_txtEmail'];
    $OppLogin_txtPwd=$_REQUEST['OppLogin_txtPwd'];
    $OppLogineleSubmit=$_REQUEST['OppLogineleSubmit'];
    $go=$_REQUEST['go'];
    if($go=="yes"){
    if($OppLogin_txtPwd==""){
    $err="yes";
    $err_msg.="<li>Password is required </li><br/> ";
    }
    if($OppLogin_txtEmail==""){
    $err="yes";
    $err_msg.="<li>Valid IBO NO is required </li><br/> ";
    }
    if($err!="yes"){
    if($auth->login($OppLogin_txtEmail, $OppLogin_txtPwd)){
    $auth_info = $auth->getAuthInfo();
    $_SESSION['associateslogin'] = $auth_info['email_address'];
    $_SESSION['user_type'] = $auth_info['type'];
    header('location:associates/index.htm');
    }else{
    $err="yes";
    $err_msg = 'Authentication failed. Please re-enter and try again.';
    }
    }
    }
    ?>

    Authenticate Class Script:


    <?php
    class Authenticate{

    private $db = null;
    private $db_settings = array();
    private $ibo_info = array();

    public function __construct(){

    require_once('classes/config.class.php');
    $config = new Config();
    $db_settings = $config->getDBInfo();
    $this->db_settings = $db_settings;

    $db = mysql_connect('localhost','edgest_1', 'sp9jXgy8');
    mysql_select_db('edgest_db1', $db);

    $this->db = $db;
    return true;

    }

    //Authenticates a user against a db entry
    public function authenticateVistor($access_code){

    $db = $this->db;

    //Retrieve the db entry
    $sql = 'SELECT `ibo_number`, `ibo_name`, `email_address` FROM `user_info` WHERE `ibo_number`="'. $access_code .'"';

    //Query the db
    $query = mysql_query($sql, $db);

    //Check to see if a result was returned
    $num_rows = mysql_num_rows($query);

    if($num_rows > 0){

    //Retrieve the returned resultset and assign local copies of each piece of information
    $row = mysql_fetch_assoc($query);
    $this->setAuthInfo($row);

    return true;

    }else{

    return false;

    }

    }

    public function getAuthInfo(){

    return $this->ibo_info;

    }

    //Sets the member copy of the db retrieved info
    public function setAuthInfo($info){

    $this->ibo_info = $info;

    }

    public function isAuthenticated(){

    if(!(isset($_SESSION['ibo_number']))){

    return false;

    }else{

    return true;

    }

    }

    public function login($ibo_number, $password){

    $db = $this->db;

    $sql = 'SELECT `ibo_number`,`type` FROM `logins` WHERE `ibo_number`="'.$ibo_number.'" AND `password`="'.$password.'"';

    //Query the db
    $query = mysql_query($sql, $db);

    //Check to see if a result was returned
    $num_rows = mysql_num_rows($query);

    if($num_rows > 0){

    //Retrieve the returned resultset and assign local copies of each piece of information
    $row = mysql_fetch_assoc($query);
    //$this->setAuthInfo($row);

    return true;

    }else{

    return false;

    }
    }

    public function logout(){

    session_destroy();
    header('location:index.php');
    exit();

    }


    }
    ?>

    Everytime I try create a session for the user after he has successfully logged in I get the following error message:

    "Cannot send session cache limiter - headers already sent Error"


    Contact Details

    Email:nathan@theformula.co.za




    Thank you.

    Nathan Roach

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    headers already sent message usually indicates that something has already been sent prior to your request to start a session. sometimes that can be you have sent some data, sometimes it means you have something wrong with the script and it is sending hiden or blank/spaces to the user.

    at first glance I think your problem lies in
    Code:
    <? session_start();?>
    <?php
    require_once('includes/authenticate.class.php');
    I'd move the session start into the start of the <?PHP block
    eg
    Code:
    <?php
    session_start();
    require_once('includes/authenticate.class.php');
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •