Storing a variable through new client connection/reboot


First time posting here. I've been discovering and scrolling through everything I could find in this community. What a gem O-S-C is !

I've stumbled upon something though : I need to store a variable and recall it later.
This is fairly basic, and works well inside the same client's session, using the variable widget.
But it doesn't seem to store a value whenever a new client connects, or a client reloads the interface.

What I did to debug it is create a text widget and assign the variable's value to its value (using @{variable_id} in the text widget value field), that way I can visually check the stored value.
But the text goes back to "undefined" whenever any of the mentioned case happens.
Is it the normal behaviour ?

Thanks in advance, and excuse me if this was previously answered, I couldn't find any answer to that exact question.

edit: I might have created another topic for the same question. I have deleted it, but I don't know if it's still visible... if so, another sorry.

Found a messy workaround by sending OSC messages like this:

send('ip:port', '/EDIT', 'variable_id',{"value":"${get("widget_id")}"});
send('ip:port', '/SESSION/SAVE');

It now works the way I wanted it to, but there is a notification when the session is saved, plus the documentation says sending '/EDIT' OSC messages is CPU expensive.

I did a quick test and variable widget are synchronized accross clients as expected so there should be no need for hacky workarounds here. Did you set the variable's bypass property to true ? If so that'd explain why it doesn't sync.

Note that in the case of a client reloading, there must be at least one other client that stays connected to keep the state of widgets alive. If you want values to persist regardless of that, you need to write a custom module that stores and restores the values.

Thanks for your quick reply Jean-Emmanuel !

No bypass property is set to true inside the whole project, but I think the need to keep at least one connected client could explain why it behaves that way.
My setup is intended to run on a headless RPi for now, hence I'd like to be able to store and recall variables even when there is no connected client at some point.

I thought about exporting variables to, say, text files (I don't mind having tons of text files inside a specific folder), but I'm totally lost regarding how to do that.
Doing this would allow me to share variables between clients at any given time, and persist through reboots of the RPi, plus I'm building a template that could be duplicated a number of times thanks to the "Paste ID+1" function (which is fantastic btw), and I'm wondering if a custom module wouldn't require modifying it everytime I'd like to add a new variable?
Maybe I don't get what a custom module does, after all...

The structure of O-S-C allows to imagine a huge lot of possibilities, thanks for that.