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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看