2

I have the session id in {this.state.session}. I want to call that session state throughout the application by set cookie or to store the asyncstorage.

Can you please give the code to set asyncstorage or set cookie?

Bogdan Sorin
  • 129
  • 3
  • 14
Manikanta
  • 325
  • 6
  • 20
  • Have you checked this: https://stackoverflow.com/questions/44353193/set-up-cookie-for-the-component-in-react-js – salman.zare Mar 28 '18 at 05:28

1 Answers1

0

I'd suggest you to use a state management library such as Redux which will enable you to access the variable anywhere in your application through props. If you still need to store your session Id in asyncStorage, Here is the code

try {
    await AsyncStorage.setItem('SessionId', this.state.session);
} catch (error) {
    // Error saving data
}

try centralizing it to the store so that you don't access asyncStorage everywhere.

Aayush Anand
  • 254
  • 2
  • 10