我有一個基於Web的系統,基於會話變量建立用戶登錄數據。當我用php/html導出文件我的會話數據重置
有時,當用戶登錄並嘗試將表導出到csv或xls時,會話數據似乎被擦除,用戶被「踢出」系統。
這是我用來提供文件的標題代碼。
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=file.xls");
header("Content-Transfer-Encoding: binary ");
如果它有幫助,它似乎在ie6上更普遍。我想知道是否有人有類似的問題。
這是我試過的最新的頭文件。仍然沒有運氣。還測試了完全相同的程序在FF /歌劇/ Safari和他們很好。
header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0', false); // HTTP/1.1
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Expires: 0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: no-cache');
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment;filename=$fileName");
header("Content-Transfer-Encoding: binary ");
expires標題應該採用這種格式(yes GMT):過期:1994年12月1日星期四16:00:00 GMT – OIS 2009-09-03 15:34:31