当我发送下载头时,IE7会清除会话

时间:2010-12-15 14:44:48

标签: php internet-explorer-7 http-headers

因此,如果IE7尝试从我的网站下载文件,IE7会不断记录我的客户端。使用下载脚本间接下载文件:

private static function SendHeaders($theFileNameServer=NULL, $theFileNameClient, $theMimeType, $theSize)
{
    $aBegin = 0;
    $aEnd = $theSize;

    // fix for IE catching or PHP bug issue
    header('Pragma: public');
    header('Expires: 0'); // set expiration time
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    // browser must download file from server instead of cache

    // force download dialog
    header('Content-Type: application/force-download');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/download');

    // use the Content-Disposition header to supply a recommended filename and
    // force the browser to display the save dialog.
    header('Content-Disposition: attachment; filename='.$theFileNameClient.';');

    /*
    The Content-transfer-encoding header should be binary, since the file will be read
    directly from the disk and the raw bytes passed to the downloading computer.
    The Content-length header is useful to set for downloads. The browser will be able to
    show a progress meter as a file downloads. The content-lenght can be determines by
    filesize function returns the size of a file.
    */
    header('Content-Transfer-Encoding: binary');
    header('Content-Length:'.($aEnd-$aBegin));

    self::FlushX();
}

private static function FlushX(){
    // check that buffer is actually set before flushing
    if (ob_get_length()){           
        @ob_flush();
        @flush();
        @ob_end_flush();
    }   
    @ob_start();
}

所以,似乎缓存标题在某种程度上混淆了IE7并使其转储所有cookie或其他内容。

此问题的解决方法是什么?我的登录系统在Firefox,Chrome等中运行良好。

0 个答案:

没有答案