开发者

CodeIgniter controllers being called twice

It is entirely possible that I've made a huge mistake someplace, but for some reason, my controllers are being called twice. This is breaking DX_Auth's captcha's on Chrome, but somehow, Firefox and IE can handle it.

The problem is, every controller is getting called twice milliseconds apart. I used log_message() to print every key/value pair from the $_SERVER superglobal.

The only differences are:

1st Call

'HTTP_CACHE_CONTROL' => 'max-age=0'
'HTTP_ACCEPT' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
'HTTP_COOKIE' => 'ci_session=a:4:{s:10:"session_id";s:32:"4be9cef4e2cdae468c7443f52a5fb3f2";s:10:"ip_address";s:13:"321.321.321.321";s:10:"user_agent";s:50:"Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US)+Ap";s:13:"last_activity";s:10:"1282151409";}70b300096c8d40c60a676ac65bcb222c'
'REMOTE_PORT' => '61828'

and the 2nd Call

'HTTP_CACHE_CONTROL' => NULL
'HTTP_ACCEPT' => '*/*'
'HTTP_COOKIE' => 'ci_session=a:4:{s:10:"session_id";s:32:"a5bb2c98a8ff4438cef3a3fe3d5ff73e";s:10:"ip_address";s:13:"321.321.321.321";s:10:"user_agent";s:50:"Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US)+Ap";s:13:"last_activity";s:10:"1282151734";}4adf1de21f9708d66b3d4bc36d0b0d92'
'REMOTE_PORT' => '61842'

There is a thread already on the CI forums where someone else had a similar problem, but his problem turned out to be spyware. This is not the case for me. I tried on several computers and none of my visitors can register for the site.

You see, DX_auth stores the value of the captcha as CI session flashdata on the first call. The second call wipes the flashdata and no one can ever get the captcha correct as a result.

Here is a sample of my access logs

123.123.123.123 - - [18/Aug/2010:12:31:26 -0500] "GET /welcome HTTP/1.1" 200 3391 "http://somewhere.com/[age" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.126 Safari/533.4"
123.123.123.123 - - [18/Aug/2010:12:31:27 -0500] "GET /welcome HTTP/1.1" 200 3391 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.126 Safari/533.4"

As you can see, the first call seems to be coming from me, and the second call has no referrer.

I thought there was a problem with the .htaccess file I used to eliminate index.php from the uri. So, I switched to the "default" .htaccess redirect as stated in the CI documentation. The double load still happens.

RewriteEngine on
RewriteCond $1 !^(index\.php|asset|captcha|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

I also used FireFox's "Live HTTP headers" plugin. It looks like only one request is being sent, but FireBug's console show that two replies are coming back.

Anybody know what's going on? Has th开发者_如何转开发is happened to anyone else?


See my reply to a similar question to get some idea of what can cause this, and how you can begin to identify the exact problem: Controller actions being called twice --- Php application


i experience the same problem and that drive me mad. the request is actually come from firefox. the firefox browser send the request twice. so it wasn't codeigniter side error. try to use another version of firefox. it should be fix the problem.


I've run into behavior that looked like this when binding events with jQuery on DOM elements based on a response, and forgetting that you need to unbind the old event on that DOM element.


My issue was this and the page being reloaded on this meta tag. Removed it and the Firefox double loading stopped.

<meta http-equiv="Content-Type" content="text/css; charset=utf-8" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜