Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to use session in Xamarin Android after login

I have created a registration page and now would like to take inputs on like User Name and Password and create session for that user. Also would like to maintain this session for some time period. Also add Logout link on the page after successfull login.

Please share with me some code or links so I can achieve it.

I searched for the same, I got some reference to implement this by using Shared Preference.

Thanks

Answers

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    There is no code since you're creating your own logic. You should call http task for session and check if user exist and response returns ok. Then you must save user info ( name, last name, api token etc. ) with shared preferences. You also need a some boolean in shared preferences like isLoggedIn for example to start different activity after user logged in. You can check isLoggedIn in splash screen activity.

  • HistoryaHistorya USMember ✭✭✭

    @BerayBentesen how to save user info with :
    Android: SharedPreferences
    iOS/macOS: NSUserDefaults
    Windows Phone: IsolatedStorageSettings
    Windows RT / UWP: ApplicationDataContainer
    i need to save the user's token i couldn't understand how to use the Xam.plugin.setting to do that!? any help!

Sign In or Register to comment.