KubeR Posted September 3, 2013 Share Posted September 3, 2013 Hi, Hm,I've been trying to do this in many different ways,but I never came into solution. The problem is that I have two pages,one for login second for MySQL check and redirection back to the index page. now,I have Private SSL installed and I set the redirection in .htaccess to redirect from http to https. when the user types in the login id & password,then being redirected to the login check page and then quickly back to the index,I create a cookie which holds the result from the MySQL(small,just plain numbers) and I want to delete it once he reaches the index.php. Now,the problem is that it doesn't delete the cookie and at the same time outputs this warnning: Warning: Cannot modify header information - headers already sent by (output started at /home3/kirill/public_html/index.php:1) in /home3/kirill/public_html/cdel.php on line 5 (I created a file named "cdel.php" for it to load in different file before the output & extrenal output buffer(ob_start),both(together & seperated) didn't work and gave the same warning and I didn't step forward to the solution) So,I ask to help me a bit with it(?),as I am just out of idea's and not familiar yet with all PHP features & solutions/problems. Before the hand,thank you. KubeR. Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/ Share on other sites More sharing options...
requinix Posted September 3, 2013 Share Posted September 3, 2013 PHP Resources & FAQs:I'm getting a "headers already sent error". What does that mean? Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448033 Share on other sites More sharing options...
KubeR Posted September 4, 2013 Author Share Posted September 4, 2013 Yes,but as I already said,I tried this already. The code is located before anything even starts,in a seperated file,included in the file using the "include" function and has an OB in it. This is the code in case maybe it's needed or maybe if the problem is in my code : (these are lines 1 & 2) <? include("cdel.php"); if(!isset($_COOKIE["i"])) {?> cdel.php: <? ob_start(); function delCookie($name) { unset($_COOKIE[$name]); return setcookie($name, NULL, -1); } if(isset($_COOKIE["1"])) { $failed1=$_COOKIE["1"]; delCookie("1"); } if(isset($_COOKIE["2"])) { $failed2=$_COOKIE["2"]; delCookie("2"); } ob_end_flush(); ?> I did try the solutions above,but yet,same problem apears. Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448077 Share on other sites More sharing options...
mac_gyver Posted September 4, 2013 Share Posted September 4, 2013 In order to pin down what might be causing the output on line 1 of your index.php file, only put the php opening tag on line 1, with no other php statements on line 1 by also putting the include statement on line 1, you cannot tell if something before the opening php tag is causing the output or if something in the include file is causing the output. and get rid of the output buffering statements. you should only use them when you WANT to buffer output, not to try to fix problems in your code, and in this case there's nothing in the body of your code that is even producing output, so they had no effect. Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448079 Share on other sites More sharing options...
KubeR Posted September 4, 2013 Author Share Posted September 4, 2013 I cut it to the first line as I thought maybe the line was the problem,however I tried to find the problem by deleting the https:// redirection in .htaccess and lowering the php tag by one line and the warning came from the opening tag and not from the first line which was empty. Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448081 Share on other sites More sharing options...
mac_gyver Posted September 4, 2013 Share Posted September 4, 2013 the line number where the error message reports that the output occurred at is the last line of the output. moving the opening php tag down just added intentional output before the opening php tag. put the opening php tag on line 1, with nothing else on line 1 and what error do you get? Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448085 Share on other sites More sharing options...
KubeR Posted September 4, 2013 Author Share Posted September 4, 2013 I just tried to look for the problem in the script when I did that,anyway,the answer for your question is : same. Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448087 Share on other sites More sharing options...
mac_gyver Posted September 4, 2013 Share Posted September 4, 2013 then your file has likely been saved by your editor with the utf-8 Byte Order Mark (BOM) characters. either save your file without the BOM characters or don't save it as a utf-8 encoded file at all (if it doesn't contain any urf-8 encoded characters.) Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448088 Share on other sites More sharing options...
KubeR Posted September 4, 2013 Author Share Posted September 4, 2013 Indeed,I saved it as UTF-8,converted/set it to UTF-8 without BOM and it fixed the warning,thanks ! Link to comment https://forums.phpfreaks.com/topic/281827-a-bit-complexed-question-about-cookies-being-deleted-before-the-output-starts/#findComment-1448092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.