Re: Cookies and sent headers
| From: | Otto Wyss | Date: | Sat, 18 Aug 2007 14:39:29 +0000 |
| Subject: | Re: Cookies and sent headers | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260994@lists.php.net to get a copy of this message | ||
ob_start() at the beginning and ob_end_flush() at the end of the PHP section seems to do the trick albeit I've still problems to understand why. The description in the manual is rather sparse unfortunately. Is there any more information about what's going on?
O. Wyss
Wouter van Vliet / Interpotential wrote:
You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your <?php opening. To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is:php_flag output_buffering OnGood luck! On 18/08/07, Kelvin Park <kelvinpark86@gmail.com> wrote:Kelvin Park wrote:Otto Wyss wrote:-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpIf built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) {ob_start() might helpif (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires); setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires); setcookie ("l.Email1", $_SESSION['l_Email1'], $expires); setcookie ("l.Email2", $_SESSION['l_Email2'], $expires); } echo "<script type=\"text/javascript\"> parent.location.replace('$index_php"; </script>"; exit;} O. Wyss