gwolff2005 Posted March 12, 2014 Share Posted March 12, 2014 Hi guys, I need your help.My website was working fine. On my page (guntmarwolff.com) I have amongst other things a small teaser for my wordpress blog (left bottom) (which is on another site).As I said everything is working fine, Then I installed wp touch on my blog site ( a plugin which detects if a mobile device enters the blog page). Since then I get this error message. Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w010930a/index.php:3) in /www/htdocs/w010930a/blog/wp-content/plugins/wptouch/core/class-wptouch-pro.php on line 404 When I deactivate the plugin the error message is gone.But for obvious reasons I need teh plugin. So what do I need to do. Tried already to delete all empty spaces. Did not help. Funny thing. While writing this, the error is gone in firefox but still there in chrome and IE. The error was as well shown to me yesterday evening and then after refreshing it dissappear until this morning...But at the same time the error is shown on other devices as well. So it is not because of my settings. Here is the code around index.php:3 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <?php if(isset($_GET['mVar'])){ session_start(); $_SESSION['views']=1; // Declaring a session to track the visits } if(!$_SESSION['views'] == 1){ // Checking the session and doing the redirection and here is the code around class-wptouch-pro.php:404 } } if ( !isset( $_COOKIE[ WPTOUCH_CACHE_COOKIE ] ) || ( isset( $_COOKIE[ WPTOUCH_CACHE_COOKIE ] ) && $_COOKIE[ WPTOUCH_CACHE_COOKIE] != $cookie_value ) ) {setcookie( WPTOUCH_CACHE_COOKIE, $cookie_value, time() + 3600, '/' ); $_COOKIE[ WPTOUCH_CACHE_COOKIE ] = $cookie_value; } if ( !is_admin() ) { do_action( 'wptouch_cache_page' ); } } Thnaks so much in advance for your help. Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/ Share on other sites More sharing options...
trq Posted March 12, 2014 Share Posted March 12, 2014 You have a bunch of output prior to session_start(). Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/#findComment-1472266 Share on other sites More sharing options...
Solution subhomoy Posted March 12, 2014 Solution Share Posted March 12, 2014 use ob_start(); on top of the page i.e on line 1.. It flushes out the existing data fromthe server before sending any message. Hope it helps... Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/#findComment-1472267 Share on other sites More sharing options...
gwolff2005 Posted March 12, 2014 Author Share Posted March 12, 2014 @ subhomoy Thank you!!! Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/#findComment-1472273 Share on other sites More sharing options...
trq Posted March 12, 2014 Share Posted March 12, 2014 That is a terrible hack. Just put session_start() before your output. Simple. Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/#findComment-1472399 Share on other sites More sharing options...
subhomoy Posted March 14, 2014 Share Posted March 14, 2014 @trq can u plz tell me why ob_start() is a terrible hack... Please dont mind as I am a newbie and i dont know much about php... I always got that thing working... Quote Link to comment https://forums.phpfreaks.com/topic/286903-cannot-modify-header-information/#findComment-1472585 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.