Page 1 of 1

local storage variable decides which page to load

Posted: Tue Mar 31, 2015 6:36 pm
by Jonathan Nakouzi

Hi. I've been struggling with this so I hope someone can help.

I have variable in local storage. I want to inspect its value and depending on that decide which page to go load. It must be a very common pattern, but I can't see how to do it.

e.g. user details. if undefined go to registration page otherwise go to other page

Any clues will be highly appreciated.

TIA
J


local storage variable decides which page to load

Posted: Wed Apr 01, 2015 4:55 am
by Yurii Orishchuk

Hi Jonathan,

Sure, here is a code that you need to use on goal event:

pre

//Where "localStorageVariableName" is your local storage name.
var lsvValue = localStorage.getItem("localStorageVariableName");

//Navigate to "someStartPage" is lsv is "start"
if(lsvValue == "start"){
Apperyio.navigateTo("someStartPage");
};

//Navigate to "someEndPage" is lsv is "end"
if(lsvValue == "end"){
Apperyio.navigateTo("someEndPage");
}

...........

/pre

Regards.