droe9376 2013-04-15 15:39
浏览 30

会话变量在readfile php方法中不起作用

I've the php code as below. The variable $_SESSION['url'] has value and printing as it is. Its not working if I called the session variable.

session_start();
header('Content-type: application/pdf');
readfile($_SESSION['url']);

But Its working, If we wrote as below.

session_start();
$_SESSION['url']= 'http://samplepdf.com/sample.pdf';
header('Content-type: application/pdf');
readfile($_SESSION['url']);

if anybody experienced this, how to solve this? Thanks in advance

  • 写回答

1条回答 默认 最新

  • doumo6356 2013-04-15 17:31
    关注

    The $_SESSION is variable (almost) like any other for duration of the script. So if you write it on one line of the script, you can read it later. No matter if sessions work or not in your environment.

    So it's not surprising that your second example works. And it does not show anything that could help explaining your problem.

    You should show us instead, what did you try to do to make sessions working. And where and how do you actually set the url session variable?

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)