会话意外丢失了? [英] Session unexpectedly lost?

查看:135
本文介绍了会话意外丢失了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在输出报告时遇到了一个烦人的问题。基本上,按下一个按钮,服务器端使用以下javascript生成一个报告: -



$ p $ call_portportler(true,{op: 'build',输入:exportType},function(data){
var outputURL ='./reportinc/export_controller.php?op=output&filename=';
var reportFilename = data ['filename' ];
var reportTitle = data ['title'];

if(reportFilename&& reportTitle){

var resultURL = outputURL + reportFilename +' & title ='+ reportTitle;

/ *启动下载对话框* /
if(!$('#exportFrame')。length){
var hiddenIFrame = document .createElement('iframe');
hiddenIFrame.setAttribute('id','exportFrame');
document.body.appendChild(hiddenIFrame);
}

$('#exportFrame')。attr('src',resultURL);
} else {
error('No filena我或报告标题指定!');
}
});

导出控制器的'build'操作将报告生成到服务器上的临时文件。如果成功,调用输出操作将该文件输出到隐藏的iframe,以便获得下载提示给用户。 Internet Explorer 6/7是这里使用的唯一浏览器。



这是服务器上的输出处理程序,iframe将使用成功构建的文件名进行请求: -

  / *输出处理程序* / 
case'output':{

$ filename = $ _GET [ '文件名'];

header('Content-Description:File Transfer');
header('Content-Transfer-Encoding:binary');
header('Expires:0');
header(Content-Type:application / force-download);
header(Content-Type:application / octet-stream);
header(Content-Type:application / download);
header(Content-Type:application / pdf);

/ **
*注意:这似乎是某些版本的Adobe所必需的!
* http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=15400
* /
header(Cache-Control:private);
标题(Pragma:cache);
header(Content-Disposition:attachment; filename = \file.pdf \);
header('Content-Length:'。filesize($ filename));

/ *立即为大文件刷新标题* /
ob_clean();
flush();
readfile($ filename);
@unlink($ filename);
}

我遇到的问题是:虽然这工作正常,但会话似乎在第一次成功下载文件后被销毁。也就是说,当用户导航到另一个页面时,他们似乎会生成一个新的会话ID。这也要求用户必须'重新登录',如果基本身份验证正在使用他们采取的下一个行动。



这个问题似乎非常间歇,似乎有时会发生,而不是在其他时间发生。

有没有人有任何想法?我应该添加更多的头文件或某些东西来防止用户会话被破坏吗?

解决方案

if iframe的顶级域名不等于Ie将回复到p3p协议并删除会话。添加标题可以解决这个问题。



http://weblogs.asp.net/coltk/archive/2010/10/13/session-lost-in-iframe-p3p-issue。 aspx


I'm at a loss with an annoying issue to do with exporting a report. Basically, a button is pressed and a report is generated server side using the following javascript:-

__callExportController(true, { op: 'build', type: exportType }, function(data) {
    var outputURL = './reportinc/export_controller.php?op=output&filename=';
    var reportFilename = data['filename'];
    var reportTitle = data['title'];

    if (reportFilename && reportTitle) {

        var resultURL = outputURL + reportFilename + '&title=' + reportTitle;

        /* Initiate the download dialog */
        if (!$('#exportFrame').length) {
            var hiddenIFrame = document.createElement('iframe');
            hiddenIFrame.setAttribute('id','exportFrame');
            document.body.appendChild(hiddenIFrame);
        }

        $('#exportFrame').attr('src', resultURL);
    } else {
        error('No filename or report title specified!');
    }
});

The 'build' operation of the export controller builds the report to a temporary file on the server. If that succeeds, the 'output' operation is called to output that file to a hidden iframe in order to get the download prompt to the user. Internet Explorer 6/7 are the only browsers in use here.

This is the output handler on the server which the iframe will be requesting with the successfully built filename:-

/* Output handler */
case 'output':{

    $filename = $_GET['filename'];

    header('Content-Description: File Transfer');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Type: application/pdf");

    /**
     * NOTE: It appears this is required for some versions of adobe!
     * http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=15400
     */
    header("Cache-Control: private");
    header("Pragma: cache");
    header("Content-Disposition: attachment; filename=\"file.pdf\"");
    header('Content-Length: ' . filesize($filename));

    /* Flush the headers immediately for larger files */
    ob_clean();
    flush();
    readfile($filename);
    @unlink($filename);
}

The issue I'm having is: whilst this works fine once, the session appears to be destroyed after the first successful file download. That is, when the user navigates away to another page they appear to be generated a new session id. This also requires the user to have to 're-login' if basic authentication is in use with the next action they take.

The issue seems very intermittent and it seems to happen at times and not at other times.

Has anyone any ideas? Should I be adding more headers or something to prevent the users session from being destroyed?

解决方案

if the top level domain of the iframe is not the equal the Ie will revert to the p3p protocol and deletes the session. adding a header will fix this issue.

http://weblogs.asp.net/coltk/archive/2010/10/13/session-lost-in-iframe-p3p-issue.aspx

这篇关于会话意外丢失了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆