How to flush data in php and disconnect user but keep the script alive

Posted by Rodrigo on Stack Overflow See other posts from Stack Overflow or by Rodrigo
Published on 2010-05-16T05:02:27Z Indexed on 2010/05/16 5:10 UTC
Read the original article Hit count: 257

Filed under:
|
|

This is a trick question, while developing a php+ajax application i felt into some long queries, nothing wrong with them, but they could be done in background.

I know that there's a way to just send a reply to user while throwing the real processing to another process by exec(), however it dosen't feels right for me, this might generate exploits and it's not pratical on making it compatible with virtual servers and cross platform.

PHP offers the ob_* functions although they help on flushing the cache, but the user will keep connected until the script is running.

I'm wondering if there's an alternate to exec to keep a script running after sending data to user and closing connection/thread with apache, or a less "dirty" way to have processing data sent to another script.

© Stack Overflow or respective owner

Related posts about php

Related posts about AJAX