# Context.flow vs flow.set

**URL:** <https://discourse.nodered.org/t/context-flow-vs-flow-set/21210>\
**Category:** General\
**Created:** [3 February 2020 18:34 UTC](https://discourse.nodered.org/t/context-flow-vs-flow-set/21210 "2020-02-03T18:34:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spyder0552](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spyder0552/32/14035_2.png) [@spyder0552](https://discourse.nodered.org/u/spyder0552)\
**Post date:** [3 February 2020 18:34 UTC](https://discourse.nodered.org/t/context-flow-vs-flow-set/21210/1 "2020-02-03T18:34:49Z")

</div>

Just a question as both appear to work. What is the recommended way of setting a variable?  
Should I use the flow.set('myVariable') or does context.flow.myvariable work.

Just trying to understand the correct and supported method to use.  
And yes, I am just working with flow specific and not global.

Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 February 2020 19:27 UTC](https://discourse.nodered.org/t/context-flow-vs-flow-set/21210/2 "2020-02-03T19:27:39Z")

</div>

flow.set will use the context storage api... If you set up other types of context storage then they will work correctly. - Using context.flow.myvariable will write direct to in memory context - thus bypassing the storage api - so may not end up in external storage, (if that is what you had configured), and thus survive a restart. Also it won't be reflected in the context sidebar view correctly. So ideally you should use .set - but if you only use in memory context then flow.context should work.

---

<div class="post-metadata">

**Author:** ![spyder0552](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spyder0552/32/14035_2.png) [@spyder0552](https://discourse.nodered.org/u/spyder0552)\
**Post date:** [3 February 2020 19:29 UTC](https://discourse.nodered.org/t/context-flow-vs-flow-set/21210/3 "2020-02-03T19:29:30Z")

</div>

Thanks deceejay, that confirms what I was seeing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 February 2020 19:29 UTC](https://discourse.nodered.org/t/context-flow-vs-flow-set/21210/4 "2020-02-17T19:29:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
