-1

I recently upgraded the server software to MySQL 5.6 and PHP 5.6 (which seemed to return settings in PHP.ini to default).

All of a sudden the cookies stopped working in the website, yet those for the installed pHpbb forum still work. However I debugged as far as I could, I have two pages exactly the same with the following code, one produces a cookie and the other doesn't, but instead gets the error of headers already been sent on the line of setcookie.

Page 1:

$exp = time() + 604800;
setcookie("uid6", "6678", "$exp");
print_r($_COOKIE);

Page 2:

$exp = time() + 604800;
setcookie("uid7", "6678", "$exp");
print_r($_COOKIE);

I tried changing the quotes and parameters within the function to no result.

I saw one post on this website from someone who suggested one file he had was UTF-8 with BOM, and when he turned it without BOM it worked. I don't know how to determine this because I have not set the encoding for these individual pages, which have the same permissions and no identifiable differences.

halfer
  • 19,824
  • 17
  • 99
  • 186
vaddy
  • 77
  • 7
  • 1
    "but instead gets the error of headers already been sent on the line of setcookie." --- so why have not you researched of why the error is thrown then? – zerkms Nov 29 '16 at 22:35
  • 1
    The error message also tells you where the first output happend. – CBroe Nov 29 '16 at 22:37
  • If an upgrade resets the settings to default, then most likely you replaced the files instead of performing a proper upgrade. – arkascha Nov 29 '16 at 22:39
  • Sounds like output buffering was enabled before. – CBroe Nov 29 '16 at 22:40
  • Possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Xorifelse Nov 29 '16 at 22:52
  • Well I did as CBroe suggested by setting output buffering to 4096 and it works fine. Thanks!! – vaddy Nov 30 '16 at 05:04
  • 1
    @vaddy: please remain civil when posting here. Disagreements as to whether a question is on-topic or sufficiently researched are inevitable, and your response is not warranted. I have reported it to a moderator. – halfer Nov 30 '16 at 12:44

1 Answers1

0

(Posted on behalf of the OP).

This is an idiosyncracity after an update. Setting output buffering to 4096 solved the problem, thanks to the answer from CBroe.

halfer
  • 19,824
  • 17
  • 99
  • 186