note 72772 added to function.session-write-close
| From: | tyler at n49 dot com | Date: | Thu, 01 Feb 2007 01:49:36 +0000 |
| Subject: | note 72772 added to function.session-write-close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122465@lists.php.net to get a copy of this message | ||
Along the same lines as what cenaculo at netcabo dot pt, bkatz at usefulengineering dot com, and
editorial at literati dot ca said about making sure you session_write_close(), don't forget to
ob_end_flush() if you're using output buffering.
I've been having some weird hanging issues when I tried to navigate away from a page with
content streaming in an Iframe or a separate window.
Instead of:
<?
ob_start();
session_start();
/* Do session stuff here; security; logging; etc. */
session_write_close();
/* NOW write out the requested file. */
header("Content-type: audio/x-mpeg"); /* or whatever type */
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Length: " . $filesize);
header("Content-Transfer-Encoding: binary\n\n");
header("Pragma: no-cache");
header("Expires: 0");
$file_contents = file_get_contents($filepath);
print($file_contents);
?>
Do:
<?
ob_start();
session_start();
/* Do session stuff here; security; logging; etc. */
session_write_close();
/* Make sure data is actually flushed out to the browser */
ob_end_flush();
/* NOW write out the requested file. */
header("Content-type: audio/x-mpeg"); /* or whatever type */
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Length: " . $filesize);
header("Content-Transfer-Encoding: binary\n\n");
header("Pragma: no-cache");
header("Expires: 0");
$file_contents = file_get_contents($filepath);
print($file_contents);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 74.99.232.47
----
Manual Page -- http://www.php.net/manual/en/function.session-write-close.php
Edit -- https://master.php.net/note/edit/72772
Del: integrated -- https://master.php.net/note/delete/72772/integrated
Del: useless -- https://master.php.net/note/delete/72772/useless
Del: bad code -- https://master.php.net/note/delete/72772/bad+code
Del: spam -- https://master.php.net/note/delete/72772/spam
Del: non-english -- https://master.php.net/note/delete/72772/non-english
Del: in docs -- https://master.php.net/note/delete/72772/in+docs
Del: other reasons-- https://master.php.net/note/delete/72772
Reject -- https://master.php.net/note/reject/72772
Search -- https://master.php.net/manage/user-notes.php