note 54839 added to function.session-start
| From: | bkatz at usefulengineering dot com | Date: | Sun, 17 Jul 2005 03:08:16 +0000 |
| Subject: | note 54839 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92067@lists.php.net to get a copy of this message | ||
Because session_start() does indeed prevent another page using session_start() from running until
the first one is done, i use session_write_close() before doing any operation that takes significant
time. For instance, session_write_close() worked as a lifesaver for me when automatically uploading
files to a user (forcing a download instead of a link). When files are large, my site was not able
to upload more than one file at a time to a user. By using session_write_close() before beginning
the file upload, my users can now download as many big files as they like, at the same time.
Example:
<?
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);
?>
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54839
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54839&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54839&report=yes
Search -- http://master.php.net/manage/user-notes.php