2016-12-04 2 views
0

Мне нужно скачать cookie вместе с PDF. Я добавил setcookie в следующую функцию, но он не работает. Что не так? Благодаряphp - скачать файл cookie вместе с pdf

protected function send_download($file) { 
    if (file_exists($file)) { 
     set_time_limit(0); 
     header('Connection: Keep-Alive'); 
     header('Content-Description: File Transfer'); 
     header('Content-Type: application/octet-stream'); 
     header('Content-Disposition: attachment; filename="'.basename($file).'"'); 
     setcookie("fileDownloadToken", "fileDownloadToken", time()+360); // 10 minutes 
     header('Content-Transfer-Encoding: binary'); 
     header('Expires: 0'); 
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
     header('Pragma: public'); 
     header('Content-Length: ' . filesize($file)); 
     ob_clean(); 
     flush(); 
     readfile($file); 
    } 
} 

ответ

0

Решенный :) Это было видно только, как печенье ответа. Необходимо было установить путь и домен.

  setcookie("fileDownloadToken", $fileDownloadToken, time()+360, '/', $this->template->domain); // 10 minutes 
Смежные вопросы