Gurzi Posted July 4, 2008 Share Posted July 4, 2008 Hello, i have a weird doubt and i dont know the answer. I was using the session_start in the first line of my code, and 5 lines after i had to use the header() function and of course it said that ouput already had been sent. I understood and i tried something, like this session_start() session_destroy() header() and it worked, and i dont know why , doesn't it sent ouput to the browser ?? Weird :s Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/ Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 Show me what you had in those 5 lines. =P Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581979 Share on other sites More sharing options...
Gurzi Posted July 4, 2008 Author Share Posted July 4, 2008 I was trying to develop an captcha system so i had this <?php session_start(); if($_POST['captcha'] != $_SESSION['captcha']){ header("Location: index.php"); }else{ // do something } ?> When the user entered the captcha wrong, it says that output already had been sent. So i tried this way: <?php session_start(); $test = $_SESSION['captcha']; session_destroy(); if($test != $_POST['captcha']){ header("Location: index.php"); }else{ // do something } ?> and it worked :S but i dont know the reason :x Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581987 Share on other sites More sharing options...
PFMaBiSmAd Posted July 4, 2008 Share Posted July 4, 2008 We need the error message as well. Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581991 Share on other sites More sharing options...
Gurzi Posted July 4, 2008 Author Share Posted July 4, 2008 We need the error message as well. i don't have the error anymore, and i can't put online the old way, but it is just how i said, headers already sent Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581995 Share on other sites More sharing options...
DeanWhitehouse Posted July 4, 2008 Share Posted July 4, 2008 you would only get that error if there is any output before the header being sent, e.g. echo's Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581997 Share on other sites More sharing options...
Gurzi Posted July 4, 2008 Author Share Posted July 4, 2008 you would only get that error if there is any output before the header being sent, e.g. echo's does the session_start deliver some output ? Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-581999 Share on other sites More sharing options...
ionik Posted July 4, 2008 Share Posted July 4, 2008 session_start will not conflict with sending a header there must have been some other problem causing this, white space somewhere. Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-582000 Share on other sites More sharing options...
Gurzi Posted July 4, 2008 Author Share Posted July 4, 2008 session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start. Ok, i'm not sure if it said headers or just output already sent, but in the session_start function description, it says that i throws output Link to comment https://forums.phpfreaks.com/topic/113271-output-from-session_start/#findComment-582002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.