Using HTTPS and Sessions with PHPExcel

Topics: Developer Forum, User Forum
Aug 23, 2011 at 9:15 PM

I struggled with this for a while, but thought I'd post this in case anyone runs into the same issue.

On LOCALHOST all worked fine for the code below, but when I migrated it to my production website which is HTTPS (secure), the browser would not open the generated Excel file.

I added the following to the top of my PHP script and it now is successfully opening the file in production.

  session_cache_limiter('public_no_cache');  // ADDED THIS TO THE VERY TOP OF SCRIPT 


// Redirect output to a client’s web browser (Excel2007)
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header("Content-Disposition: attachment;filename=$fname");
  header('Cache-Control: max-age=0');
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');