How to flush data in php and disconnect user but keep the script alive
- by Rodrigo
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.