note 84409 added to function.session-start

From: Date: Sat, 12 Jul 2008 23:49:31 +0000
Subject: note 84409 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-141442@lists.php.net to get a copy of this message
That's a basic, but i didn't see it here. So, for those who get the following message: Message : Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by You must avoid any characters to the output browser. Even a blank space can cause this warning and block you cookies to bet set ! For example, this code will not work ! <?php require_once('database.cls.php'); require_once('user.cls.php'); ?> <?php session_start(); ?> (because it contain a blank (space or CRLF) between "?>" and the following "<?php ?>" ) . Write instead : <?php require_once('database.cls.php'); require_once('user.cls.php'); session_start(); ?> So, careful also when you integrate your classes, with require() or include(). They must have no blank character after the end of the file. So don't let anything after the last "?>" in the class, or included file. Hope i was clear enough with my explanations ;-) ---- Server IP: 212.63.193.10 Probable Submitter: 83.233.71.126 ---- Manual Page -- http://www.php.net/manual/en/function.session-start.php Edit -- https://master.php.net/note/edit/84409 Del: integrated -- https://master.php.net/note/delete/84409/integrated Del: useless -- https://master.php.net/note/delete/84409/useless Del: bad code -- https://master.php.net/note/delete/84409/bad+code Del: spam -- https://master.php.net/note/delete/84409/spam Del: non-english -- https://master.php.net/note/delete/84409/non-english Del: in docs -- https://master.php.net/note/delete/84409/in+docs Del: other reasons-- https://master.php.net/note/delete/84409 Reject -- https://master.php.net/note/reject/84409 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141442) next »