note 54839 deleted from function.session-start by bjori

From: Date: Sun, 16 Apr 2006 00:32:30 +0000
Subject: note 54839 deleted from function.session-start by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108222@lists.php.net to get a copy of this message
Note Submitter: bkatz at usefulengineering dot com ---- 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); ?>

« previous php.notes (#108222) next »