If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Cannot send session cache limiter - headers already sent Error

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-09, 06:36
nathan@theformula nathan@theformula is offline
Registered User
 
Join Date: May 2009
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 05-28-09, 03:36
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 8,768
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On