[PHP] deleting cart items on session expire
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
You'll probably need to trigger the deletion of all expired carts with something other than trying to guess when the user closes their browser. Maybe a regular cronjob, or just do it inside your globally-included function definition script so that any hit to the website can trigger it for you, or perhaps just put it in the script that's used when creating a new cart for someone. jason - Original Message - From: "Joseph H Blythe" <[EMAIL PROTECTED]> To: "php-general" <[EMAIL PROTECTED]> Sent: Friday, February 16, 2001 3:29 PM Subject: [PHP] deleting cart items on session expire > 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
> > 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. [EMAIL PROTECTED] AppIdeas.com For a good time, http://www.AppIdeas.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
> 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. Just as an aside, there's no reason I can think of that you can't run both the Apache module and standalone binary on the same system side by side - I've been doing this for about 2 years without trouble. jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
I guess you will need to have a script sunning after a specific period of time which would check for the sessions that have expired and then remove the associated items from the cart. database. there is no way for you to know if the user closes the browser as php is a server side language. I may be wrong, but I this is what comes to my mind. best regards Ankur Verma HCL Technologies A1CD, Sec -16 Noida, UP India - Original Message - From: "Joseph H Blythe" <[EMAIL PROTECTED]> To: "php-general" <[EMAIL PROTECTED]> Sent: Friday, February 16, 2001 10:59 AM Subject: [PHP] deleting cart items on session expire > 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 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
Well, why not store the item's in the session-var? When the session dies because of timeout or user-intervention, the items dissapear too. Or store a timestamp along with the items, and refresh the timestamps as needed. Then put in a cron-job to delete out-of-date items left in the DB at regular intervals. -J 17.02.01 02:29:04, Joseph H Blythe <[EMAIL PROTECTED]> wrote: >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 > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
> Just as an aside, there's no reason I can think of that you can't run both > the Apache module and standalone binary on the same system side by side - > I've been doing this for about 2 years without trouble. > > jason However, there's no necessity to have the cgi version if you already have the modular version. All that is needed is to call the appropriate script using a tool such as 'wget'. This can be done manually or from cron as appropriate. Billy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
> However, there's no necessity to have the cgi version if you already have > the modular version. All that is needed is to call the appropriate script > using a tool such as 'wget'. This can be done manually or from cron as > appropriate. > > Billy No there's not - I think that goes without saying though. But while you're compiling Php anyway, why not re-run ./configure without the '--with-apache' and add an '--enable-discard-path' and type 'make; make install' - then you can use this awesome tool from the command line without having to invoke a http request to your webserver usng a third-party tool. jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
Thanks all, This gives me a good start, I think I will just get cron to do it at a certain time of day, the only problem is trying to tell which sessions have expired as the database is not going to know this. Regards Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] deleting cart items on session expire
On Fri, 16 Feb 2001, Jason Brooke wrote: > > However, there's no necessity to have the cgi version if you already have > > the modular version. All that is needed is to call the appropriate script > No there's not - I think that goes without saying though. > install' - then you can use this awesome tool from the command line without > having to invoke a http request to your webserver usng a third-party tool. And add to this that then you can place the script you want to run out of the web tree, just in case you run something sensitive :) My 2 cents. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]