Login for mobile apps/session variables


How do I create a login/session variables for mobile apps? I have did some searching on my own and it was recommended that I use local storage. However, this is not a true login system as data is stored on local devices rather than accounts. 

Hi Louie,

You are correct that the data is stored on the device and not in memory, mostly because of the amount of memory available on mobile devices. The local storage is a nice alternative and can be cleared when you logout for instance, which reduces the chance of sharing personal data.

If you want your settings to be shared over different devices, you should use synchronization with a server entity which can be accessed from all devices. 

Hopefully this answers you question/doubt.

Kind regards,

Remco Dekkinga

Hi Remco,

What I am trying to create is a user login system. I need each user to have his or her own set of data. Would it be possible to do that with a server sync? If so, how do I do so?



Hi Louie,

Yes their is a possibility to do that with Offline Data Synchronization Patterns. Here each user can have separate data associated with it which is offline data store in local storage, once you finish your task then Sync your date to database server. 

Hi Louie,

We have login system for mobile app on our apps and basically it works this way:

 - to register user should be online and the process is similar to normal web app.

- on login action there is a synchronisation process to load all necessary data for this user so he can use app even without internet connection.

- on each data change there is a sync process that runs when user is online.

- on logout there is local storage clear script.

- there is a possibility to store user login/password credentials on encrypted local storage and allow user to re/login even if he is offline and logged out accidentally.

Hope this will help :)



Use Android iOS Shared User Preferences Component on Forge.:


You can create a Key with name User_Session & set it's Boolean value based on Login & Log-out action. And then use it accordingly to validate throughout the App.

Note : The SharedPreferences will only be clear in two cases;

      - Either you manually clear 

     - App get's Un-Install from device




There is no concept of Session in Mobile. So the notion of Session variables in the context of mobile does not exist. 

The way I see there are two parts to your question. 

1) Regarding Login 

To understand the concept of login in Mobile Authentication, go thru the below link.


2) Session Variables 

   In general the below link talks on how to secure data on the mobile. 


You are right, you can use local storage , but this persists data across logins. One needs to explicitly clear it on logout. 

Also there a few plugins on Forge that use native features like Shared Preferences & NSUserDefaults to store key values pairs on Android & iOS respectively. 

One I developed Shared Preferences Plugin, if you would like to check this out.