Through the magic of continuations, the Cocoon Flow subsystem makes it easy to track the user's state when interacting with a web-based application.

A continuation saves the state of execution of the currently running Flowscript, and allows this state to be "resurrected" later on, typically when the user submits an HTML form that was sent with the cocoon.sendPageAndWait instruction.

This makes the typical web applications interactions much easier to manage, as the developer can write "linear" code for page flows, instead of having to keep track of the user's state manually. Our examples will show how little code is used to manage typical interactions.

Having to use JavaScript to write the Flow scripts might seem strange at first, but in practice only a few lines of Flow code will be required for a typical application, so this doesn't matter much. The reason is that JavaScript (through a modified version of the mozilla Rhino interpreter) is currently the only continuations-enabled language that can be distributed with Cocoon.