Re: deleting cart items on session expire

From: Date: Thu, 15 Feb 2001 06:26:43 +0000
Subject: Re: deleting cart items on session expire
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39845@lists.php.net to get a copy of this message
> > hey all, > > > > I was wondering how one would suggest removing items from a cart system > once the session lifetime has expired. I have it set to the default 0, > which expires the session on browser close, what I want to be able to do is > "delete * from Cart where session='$PHPSESSID'" when the user closes thier > browser window is this even possible? maybe using > register_shutdown_function or something? > > Any ideas would be great! > > > Thanks > > Joseph > Since HTTP connections are "stateless" their can be no communication initiated from the server-side that instructs the browser to tell the server that the browser has been closed. In other words, once an HTTP request has been made, the browser and server talk to each other while the file(s) is/are transferring and will not talk again until the browser asks for more. Getting any other behavior from an HTTP connection would require something to run on the client side (like a javascript). The reason your cookies go away when they have a lifetime of zero is because the browser throws them away. This really doesn't have anything to do with the communication between the browser and the server (the server didn't see that the browser was closing and delete the cookie from your machine for you). We personally run perl scripts out of cron at 2:00 every morning to clean up all tables that need cleaning. This could be done in pretty much the same manner using the PHP language if you run the CGI version of PHP. If you're already using the CGI version of PHP, there isn't any disadvantage to using either it or perl scripts to do this clean-up. If you're running the Apache module version of PHP, you'll need to find a tool that can be invoked from the command prompt (such as perl) to do this for you. Good luck... Christopher Ostmo a.k.a. tech@AppIdeas.com AppIdeas.com For a good time, http://www.AppIdeas.com/

« previous php.general (#39845) next »