Session unexpectedly lost?

I find it difficult to export a report. Basically, a button is clicked and a report is created on the 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 creates a report in a temporary file on the server. If this succeeds, the "output" operation is called to output this file to a hidden iframe to receive a download prompt to the user. Internet Explorer 6/7 are the only browsers used here.

This is the output handler on the server that the iframe will request with a successfully created file name: -

/* 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);
}

, , : , , , . , , , , . " ", .

, , , , .

- ? -, ?

0
2

session_name session_start -.

, , cookie.

0

Source: https://habr.com/ru/post/1712034/


All Articles