问题
In React Native how to Store values in session ?
I need to store login details (Username , Password) in session .
Could you Please Give any ideas.
回答1:
Use AsyncStorage
.
Example:
For save:
AsyncStorage.multiSet([
["email", userInfo.email],
["password", userInfo.password]
])
For Delete:
let keys = ['email', 'password'];
AsyncStorage.multiRemove(keys, (err) => {
console.log('Local storage user info removed!');
});
For Get:
AsyncStorage.multiGet(['email', 'password']).then((data) => {
let email = data[0][1];
let password = data[1][1];
if (email !== null)
//Your logic
});
PDTA: as Raheel mentions password
should be encrypted
.
来源:https://stackoverflow.com/questions/42627947/in-react-native-how-to-store-values-in-session