-1

I have a problem which I can't understand.

The problem occurs only on Opera 11.50 browser. I have simply write to file function. fopen, LOCK_EX, fputs, LOCK_UN, fclose.

When I normally open pages, everything is ok. But when I reload page, then string is write to file multiple times (2, sometimes 3). I checked, Function is fired only once, and echo return correct string.

Also on refresh, Opera ignores php session variable and cookies. Of course I use buffer before session start.

For any other browser, this problems does not occur.

I checked the cookies and browser settings. Also reinstalled browser. On the second PC with freshly downloaded and installed opera 11.50 is the same problem.

Any ideas?

ps: I read this related topic, but I have not found the answer for my problem there.

There is some code:

if (!isset($_SESSION['foo']) && ($check4 === false) && !isset($_COOKIE['bar'])) {

     echo "test!";

     $fileHandler = fopen(MASTER_PATH . "/data/logs/loger.txt", "ab");
     flock($fileHandler, LOCK_EX);
     fputs($fileHandler, "What?!");
     flock($fileHandler, LOCK_UN);
     fclose($fileHandler);

     $_SESSION['foo'] = true;
     $check4 = true;
     setcookie("bar");
}

When normally enter page everything is ok. When reload echo "test!" isn't run, but in the file appear two entries "What?!". Only this function has output to that file.

Community
  • 1
  • 1
  • Our magic crystal balls that would let us read your screen over your shoulder are, coincidentally in the shop. Since we can't examine your code, we'll have to blame aliens for your problem. Their mothership is in orbit and its signals are interfering with your PC. – Marc B Jan 25 '14 at 03:36
  • I'll bet that's why it's affecting me as well. I must've left my aluminum hat on board the mothership. Let's hope it runs out of gas so I can catch up to it. @MarcB – Funk Forty Niner Jan 25 '14 at 03:50
  • Why are you focussing on a 3 years old version of Opera? People have moved on looong ago. The chance of someone actually visiting your website using that version of the browser would probably be somewhere around 1 in 7 billion, or so. – Sverri M. Olsen Jan 25 '14 at 04:37
  • The problem occurs on all Opera ver equal and below 12. This last versions with presto engine and are still popular. But the main reason is: **I must know why this is happening?! Or I go crazy.** :) – user3234164 Jan 25 '14 at 10:07

1 Answers1

0

After a week of fighting and one day waiting for help, in the end, I found the answer.

Opera with every refresh, created a new invisible session, which does not affect main session, but session dependent function lost access to correct session, and have new one only for time of refresh. The number of files in session_save_path grew with every reload. It's a browser issue.

There is info about this: http://www.blog.paranoidpenguin.net/2011/03/opera-11-the-php-session-bug/