I found what is the problem:
Im taking one of the templates that when the start of layout all the variables are reseted.
This means in layout 1 i change the variable and when i changed to layer 2 is changed to the original value because of the "on start of layout reset all the variables".
So the solution for me was in layout 1 save the value with webstorage and in layout 2 after the reset load the value saved before.