Friday, April 22, 2011

PHP Gotcha! Running 2 php process via same Session ID

If you came accross requirement to run 2 or more php execution via ajax or cron,
with same Session id, you will meet 1 fallback to the 2 process.

The 2nd php process cannot end until the first process end.
Therefore, if you have a big file uploading on 1 ajax call, and you may call another ajax later,
all your other ajax have to wait for the initial big file uploading to be done before this ajax can fully end.
The 2nd process will execute everything until all register_shutdown_function function is executed, but will not exit until 1st process is done.

This is logically acceptable as you may not want 1 session changes to mixed up with another session changes between 2 processes.
But hope this will save you some time on it...

No comments: