Question

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.

Était-ce utile?

La solution

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top