fourteen00 Posted January 13, 2008 Share Posted January 13, 2008 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: 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: 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. Quote Link to comment https://forums.phpfreaks.com/topic/85753-help-with-a-warningplease/ Share on other sites More sharing options...
toplay Posted January 13, 2008 Share Posted January 13, 2008 Pinned topic: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/85753-help-with-a-warningplease/#findComment-437652 Share on other sites More sharing options...
twostars Posted January 13, 2008 Share Posted January 13, 2008 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: 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: 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) Quote Link to comment https://forums.phpfreaks.com/topic/85753-help-with-a-warningplease/#findComment-437686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.