I need to implement Login-Logout Functionality in Windows Store App. I am new in the world of mobility. I want to know, how to maintain session for a logged-in user. How to implement automatic logout functionality after certain time. Is there any Session State like ASP.NET in Windows Store App?
I learn from the following link that there is no Session State in WPF: Session in WPF?
One of the answers suggested to use static class with public static properties for the values that we need to store and to access globally inside the application.
Do I need to use static class with public static properties for the values I have to use after Login in Windows Store App?
Please provide some sample code with your answers.
If it is possible in your case, I would take a look at Azure Mobile Services. They offer authentication backend where user can login using for example Facebook or Twitter login without needing to create another user account just for your app. There's a good sample for Universal Apps at https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-get-started-users/ which covers pretty much everything beside the time out.
If you are logging in to your own custom backend, I think a good way to implement such functionality is using the sample above.
Generally I would be hesitant to implement such timeout functionality, as there's not really a light way of doing such. Quickly thinking you would need to implement timer and maybe a base class for all views which always resets the timer when any of its events gets called.
I would suggest that you rather implement it such way that when the user navigates away from the app it logs user off. In tablet and mobile its quite rare that user leaves the app on the screen for such long time that either the OS don't suspend the screen (and the app) or the user navigates away to the main screen or to some other app.