Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29498 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52076 invoked by uid 1010); 17 May 2007 18:40:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 52060 invoked from network); 17 May 2007 18:40:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 May 2007 18:40:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain l-i-e.com from 67.139.134.202 cause and error) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:1213] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/03-10325-291AC464 for ; Thu, 17 May 2007 14:40:20 -0400 Received: (qmail 90831 invoked by uid 98); 17 May 2007 18:40:18 -0000 Received: from 127.0.0.1 by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.01 (clamdscan: 0.88.7/3264. Clear:RC:1(127.0.0.1):. Processed in 1.757634 secs); 17 May 2007 18:40:18 -0000 Received: from localhost (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 17 May 2007 18:40:15 -0000 Received: from 208.54.67.44 (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Thu, 17 May 2007 13:40:15 -0500 (CDT) Message-ID: <1574.208.54.67.44.1179427215.squirrel@www.l-i-e.com> In-Reply-To: <38.B7.39652.C93F9464@pb1.pair.com> References: <38.B7.39652.C93F9464@pb1.pair.com> Date: Thu, 17 May 2007 13:40:15 -0500 (CDT) To: "Emil Ivanov" Cc: internals@lists.php.net Reply-To: ceo@l-i-e.com User-Agent: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] register_session_gc_handler proposal From: ceo@l-i-e.com ("Richard Lynch") On Tue, May 15, 2007 12:53 pm, Emil Ivanov wrote: > Sorry to bother you, as I know you are quite busy, but I have a > problem and > maybe a elegant solution does not exist right now. > > The case is simple: > A user is allowed to upload files to the server, which are store in a > temporary location and their filenames are stored in the session. Store the filename somewhere else as well? > The user leaves the site and the session gets destroyed, but the files > remain untouched. > If I can hook to the gc session function that will solve my case, but > currently with session_set_save_handler I have to rewrite session > handling, > which I don't need... You'd only need to override the session_destroy function, and, as I recall, you can override just ONE of the functions somehow... By passing in NULL for the other args to session_set_save_handler maybe? Or maybe that was just a proposal of how to do that... > So a simple hook will be very useful. A simple HACK and probably a Bad Idea would be to cron a walk through every session file and make an array of the files in user and then the directory of files uploaded hanging around and array_difference the two and nuke the unused files. Just be SURE you always set the $_SESSION var and call session_write_close *before* you move the file, or you'll end up with a race condition where you end up nuking a file that hasn't had its session data written to disk yet. Document the hell out of this if you do it, or you'll end up re-factoring and messing that race condition up, and you'll have an intermittent bug that appears mostly under heavy load, probably. [shudder] > I know there are problems as how will I know which entry has been > destroyed... Overriding the session handler is not all that hard, really, and probably the best available widely-understood idiom. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?