简体   繁体   中英

Can localstorage values be modified outside app?

I am developing mobile app using jQuery mobile and phonegap. In that I have developed user login functionality and maintained loged in user id in localstorage, So I can relate user activities.

My application is working correctly, But I am worried about external modifications in localstorage. Can it be possible to modify localstorage values outside application.

Code In app : localStorage.setItem("userid", 60);

Can user modify it manually Or it is safe to use?

If it is any kind of secured data, then it is safe to use Shared Preference in android.

SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
editor.putString("KEY","VALUE");
editor.commit();

You can access it by plugin.

Similar question is asked here go through it - How to store a json data securely in phonegap android?

The localStorage saves it's key/value pairs per domain ( Same-origin-policy ). Since a phonegap app will get its own "domain" you do not need to be worried about other apps modifying your variables.

Also see this question right here: In HTML5, is the localStorage object isolated per page/domain?

Nevertheless, I would recommend to not save any sensible data on the client side, it would be better to do this on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM