dsfdsf23423 2010-06-02 21:08
浏览 61
已采纳

来自IE的会话数据不一致 - 缓存会话?

I'm trying to prevent some basic click-fraud on my site, and am building links based on session time data.

Everything works in FF, but in IE the information I'm storing in the session is somehow being changed.

When I load up the main page, I set my session variables like this

session_start();
$_SESSION['time']=time();

I'm out putting the session value into the page, so I get something like 1275512393.

When the user clicks on a link, I send an ajax request, and that page is returning the session which I am putting into an alert.

session_start();
echo $_SESSION['time'];
die();

The alert is returning 1275512422.

Only in IE is the $_SESSION['time'] being returned different from the original $_SESSION['time']

It doesn't appear that this is a caching issue, as the times are always VERY near each other, and the second one is always after the first, but I'm not positive.

--------update - issue caused by facebook javascript . no solution yet --------------

As i was stripping out code to post as recommended per MANCHUCK, I started to wonder if this bit of Facebook code was somehow causing the problem

FB.ini({appId: 'myappid', status: true, cookie: true, xfbml: true });

so I stripped that out and ran the page again, and now the $_SESSION times matched!!

So I found the problem. I thought maybe somehow that FB javascript was creating a session (note I'm only useing FB javascript, not the PHP api) that was somehow overwritting the values of my previous session.

I put the offending javascript back, and I tried changing the name of my session to $_SESSION['mytime'] or $_SESSION['time2'], but the problem still existed. I tried using other time functions like date('Y-m-d G:h:s'), or date('Y-m-d G:h:s').'test' but the time is always incremented by a few seconds when retrieving the $_SESSION from the second page.

I am amazed that something like this can happen, and can't imagine how it is possible, but I've gone back to it 4 times now, and every time I take out that one line of Javascript, everything works!

Unfortunately, not using facebook connect isn't really an option for this project.

  • 写回答

1条回答 默认 最新

  • dougui1977 2010-06-03 14:25
    关注

    My guess is that the main page is being executed twice, which is causing the session to restart with a new value assigned to $_SESSION['time']. That is why it is always slightly incremented. Look at your web server logs, or use Fiddler to see if the page is being requested twice. If so, this may help.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度