Session Variable getting reset on moving from one page to another

I am using Session variables to store language preferences. There is a dropdown to select the language , and also on app load there is a condition that if variable is null then set pref to english else do nothing

But i seem to be doing something wrong and cannot figure out what it is

If i select German on by home page and then move to sign up page it goes back to english

Code on both home page and sign up page is

<body is="dmx-app" id="index" class="style2 style1" 
dmx-on:load="run({condition:
{if:'session.data.preferredLanguage=null',
then:{steps:{run:{action:
`session.set(\'preferredLanguage\',\'en\');
session.set(\'preferredLanguageFull\',\'English\');
session.set(\'nativeLangValue\',1)`}}}}})">

Drop down code on both pages is :

<div class="dropdown-menu" aria-labelledby="dropdown1">
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','en');session.set('preferredLanguageFull','English');session.set('nativeLangValue',1)">English</a>
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','de');session.set('preferredLanguageFull','Deutsch');session.set('nativeLangValue',2)">Deutsch</a>
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','ja');session.set('preferredLanguageFull','日本語');session.set('nativeLangValue',3)">日本語</a>
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','ko');session.set('preferredLanguageFull','한국어');session.set('nativeLangValue',4)">한국어</a>
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','es');session.set('preferredLanguageFull','Español');session.set('nativeLangValue',5)">Español</a>
                        <a class="dropdown-item"  dmx-on:click="session.set('preferredLanguage','hi');session.set('preferredLanguageFull','हिन्दी');session.set('nativeLangValue',6)">हिन्दी</a>
                    </div>

What am i doing wrong , the moment i navigate to either page the language resets to English

Thanks

Community Page
Last updated: