Here is my code. Its working properly and now i want to compress the csv file before generate. Anybody please suggest me what to do!
$filename = 'Product_Export_' . date('Y-m-d') . '.csv';
header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename=' . $filename);
echo "\xEF\xBB\xBF"; // UTF-8 BOM
// clean the output buffer
ob_clean();
echo trim($_SESSION['cProductCSVdata']);
$_SESSION['cProductCSVdata'] = '';
exit;