When you write your flowscript in cocoon, if you declare a global variable, this was stored in session (implicit creation of session).
var i;
function count() {
cocoon.sendPage("view-count", {"counter": ++i});
}
This work propertly but
var i=0;
function count() {
cocoon.sendPage("view-count", {"counter": ++i});
}
doesn’t, this set ‘i’ to 0 each time that the script was executed. So if you need to initialize it one time only, you must check the status
var i;
function init() {
if (i == undefined) {
i = 0;
}
}
function count() {
init();
cocoon.sendPage("view-count", {"counter": ++i});
}