dqysi86208 2011-02-12 12:48
浏览 49
已采纳

CodeIgniter:index()开始调用3次?

I've encountered a weird problem. It seems that some of my controllers' index() methods are being executed 3 times when it should only be doing it once. The reason I found this out is because I am logging the number of times the index() method is executed -- and noticed records being inserted in 3s.

At this point, I am at a complete lost. I am unable to describe the problem any further as it is just very odd to me. Any ideas what might be happening?

UPDATE: It seems that the problem only exist when I have JavaScript turned on. When I turned of JavaScript, I no longer get the multiple entries. The problem controllers do have JavaScript. The JS is just some FB plugin and Google AdSense stuff.

  • 写回答

1条回答 默认 最新

  • doudun8705 2011-02-12 13:32
    关注

    I once had this kind of problem, the delay between requests was about 2-5 seconds. The cause was google adsense. It somehow makes another request from it's own server for no reason to the same page. To verify it, just store every requests IP and the user agent, if IP's (user agents too) are different, then you know the cause.

    Solution? Give the user some kind of a token before visiting next page - if the token doesn't match on the next request - it's not the same user. Something like a XSRF protection :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题