Greetings.

I was astounished by the idea behind register_shutdown_function(), since it was the perfect solution for my problems with a web system developed in PHP.

The problem, as I've soon discovered, is that the function registered by this command is always called, meaning that even if a PHP script ends normally the shutdown function is called, messing everything up - since my registered function is intended to unregister sessions and so on IF a script dies abnormally.

Is there a workaround on this? I mean, I'd love that the function is still called if the user closes the browser or hits the stop button. The problem is I don't want it to be called if a script ends normally. Maybe I can do something with exit(int status) ?

Even if I can do something with exit(), what about if a script redirects to other, via the header() function?

Thanks in advance for the enlightment,

    Write a Reply...