douqing5981 2012-03-22 04:26
浏览 106

从$ _SERVER ['REQUEST_URI']命名$ _SESSION var会神秘地命名页面“blank.gif”

Seems like such a simple problem but I'm out of options here...

So I want to set up a session variable that tells me the last page visited. I thought I could do this by declaring 2 session variables in a php include at the top of every page.

    session_start();    
    if(!$_SESSION['this_url']){
           // will only be declared once
           $_SESSION['this_url'] = $_SERVER['REQUEST_URI'];
        }

        if($_SERVER['REQUEST_URI'] != $_SESSION['this_url']){ //dont update var on page refresh
           $_SESSION['last_url'] = $_SESSION['this_url']; 
           $_SESSION['this_url'] = $_SERVER['REQUEST_URI'];  
        }

Simple enough right? But for an output it gives me this:

$_SESSION['this_url'] = /support/interactive.php (correct)

$_SESSION['last_url'] = /products/compatibility/blank.gif (right path, but blank.gif? wtf?)

it SHOULD be outputting "/products/compatibility/somepage.php" but it always replaces the page name with blank.gif.

I did a sitewide search on my site and nothing else is using my variable names. I even changed the var names and still same result. blank.gif is found in some jQuery scripts - so I suspect this may be where its coming from. But still... I'm declaring these things as the first piece of script on the page and outputting them immediately after declaring them. Is my Apache server messed up or what? this doesnt make sense.

Any ideas would be greatly appreciated, thanks!

  • 写回答

1条回答 默认 最新

  • douyi1982 2012-03-22 04:30
    关注

    Hmm, I remember trying to do something like this a while back, and I was having odd ghost problems much like you. What I ended up doing was using hidden inputs and assigning the variables to them.

    I'm not saying use hidden form elements for production, I'm just making a suggestion in case the feature you are creating is a "need now" kind of feature.

    I'm still looking as to why that may happen though, what version of Apache/PHP are you running?

    评论

报告相同问题?

悬赏问题

  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀