Best practice for variables in custom flow functions


I build some custom flow functions which require a loop. To my understanding, a loop only works with a variable I count + IF.
Now my question: Where should I define such a variable so that the custom flow function can be used across all pages?
Does it need to be an app variable?


Good question. Im guessing an App variable would be the only way.