Jump to content

Help with a warning....please...


fourteen00

Recommended Posts

Hey this is my php code... for a file :


<?php
class c5t_session
{
var $session_vars;
var $session_vars_name;
function c5t_session()
{
	$this->session_vars_name = 'MY_SESS';
}
function sess_set_vars_name($name)
{
$this->session_vars_name = $name;
}
function sess_start($sess_id = 0, $sess_name = '')
{
if (session_id() == '')
{
session_set_cookie_params(false, '/');
session_start();
}
if (!isset($_SESSION[$this->session_vars_name])) {
$_SESSION[$this->session_vars_name] = array();
}
$this->session_vars = $_SESSION[$this->session_vars_name];
}
function sess_register($data = array())
{
if (sizeof($data) <= 0) {
return false;
}
while (list($key, $val) = each($data))
{
$_SESSION[$this->session_vars_name][$key] = $val;
$this->session_vars[$key] = $val;
}
return $this->session_vars;
}
function sess_stop($sess_id = 0, $sess_name = '')
{
unset($this->session_vars);
unset($_SESSION[$this->session_vars_name]);
if (isset($GLOBALS[$this->session_vars_name])) {
unset($GLOBALS[$this->session_vars_name]);
}
}
function start()
{
global $c5t;
if (!isset($GLOBALS['session_object'])) {
$sess = new c5t_session();
$sess->sess_set_vars_name($c5t['session_vars_name']);
$sess->sess_start();
$GLOBALS['session_object'] = $sess;
}
if (isset($GLOBALS['session_object'])) {
return $GLOBALS['session_object'];
}
}
function add($data)
{
$sess = c5t_session::start();
$sess->sess_register($data);
$GLOBALS['session_object'] = $sess;
}
function get($value = null)
{
$sess = c5t_session::start();
if ($value == null) {
return $sess->session_vars;
}
if (isset($sess->session_vars[$value])) {
return $sess->session_vars[$value];
}
}
function destroy()
{
$sess = c5t_session::start();
$sess->sess_stop();
}
}
?>

 

Now im getting a warning... it says....

 

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/t/h/o/thor6329/html/test.php:8) in /home/content/t/h/o/thor6329/html/comments/include/session.class.inc.php on line 19

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/h/o/thor6329/html/test.php:8) in /home/content/t/h/o/thor6329/html/comments/include/session.class.inc.php on line 19

 

now the php page works i just get the error...its for a comment script... i checked for spaces but i do not see any at all... i also was wondering if there was a way to hide the warning so my visitors wouldnt see it maybe if theres no other way to fix it.

Link to comment
Share on other sites

Hey this is my php code... for a file :


<?php
class c5t_session
{
var $session_vars;
var $session_vars_name;
function c5t_session()
{
	$this->session_vars_name = 'MY_SESS';
}
function sess_set_vars_name($name)
{
$this->session_vars_name = $name;
}
function sess_start($sess_id = 0, $sess_name = '')
{
if (session_id() == '')
{
session_set_cookie_params(false, '/');
session_start();
}
if (!isset($_SESSION[$this->session_vars_name])) {
$_SESSION[$this->session_vars_name] = array();
}
$this->session_vars = $_SESSION[$this->session_vars_name];
}
function sess_register($data = array())
{
if (sizeof($data) <= 0) {
return false;
}
while (list($key, $val) = each($data))
{
$_SESSION[$this->session_vars_name][$key] = $val;
$this->session_vars[$key] = $val;
}
return $this->session_vars;
}
function sess_stop($sess_id = 0, $sess_name = '')
{
unset($this->session_vars);
unset($_SESSION[$this->session_vars_name]);
if (isset($GLOBALS[$this->session_vars_name])) {
unset($GLOBALS[$this->session_vars_name]);
}
}
function start()
{
global $c5t;
if (!isset($GLOBALS['session_object'])) {
$sess = new c5t_session();
$sess->sess_set_vars_name($c5t['session_vars_name']);
$sess->sess_start();
$GLOBALS['session_object'] = $sess;
}
if (isset($GLOBALS['session_object'])) {
return $GLOBALS['session_object'];
}
}
function add($data)
{
$sess = c5t_session::start();
$sess->sess_register($data);
$GLOBALS['session_object'] = $sess;
}
function get($value = null)
{
$sess = c5t_session::start();
if ($value == null) {
return $sess->session_vars;
}
if (isset($sess->session_vars[$value])) {
return $sess->session_vars[$value];
}
}
function destroy()
{
$sess = c5t_session::start();
$sess->sess_stop();
}
}
?>

 

Now im getting a warning... it says....

 

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/t/h/o/thor6329/html/test.php:8) in /home/content/t/h/o/thor6329/html/comments/include/session.class.inc.php on line 19

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/t/h/o/thor6329/html/test.php:8) in /home/content/t/h/o/thor6329/html/comments/include/session.class.inc.php on line 19

 

now the php page works i just get the error...its for a comment script... i checked for spaces but i do not see any at all... i also was wondering if there was a way to hide the warning so my visitors wouldnt see it maybe if theres no other way to fix it.

1. It doesn't matter if its a space, an echo, or just plain HTML (without PHP echoing/printing it). Check before printing is the best way to go, which is why I normally create a header.php script which will execute before anything else.

2. To silence (hide) warnings, put a @ in front of what you want to silence. (IE: The session cookie you're setting)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.