Session data is the temporary data that useses user’s current session data in the app.
To store data in session in WinJS we use WinJS.Application.sessionState.
Lets create an example for storing user’s credential in Session.
We need to add the following code snipet in the Login.html
<div style="margin-left:400px; width:200px;"> <input id="userName" type="text" /> <p style="margin-left:5px; width:200px;">Enter Name please</p> <input id="userPassword" type="text" /> <p style="margin-left:5px; width:100px;">Enter Password</p> </div> <button id="btnLogIn" style="margin-left:400px; font-size:20px; font-weight:300;"> Login</button>
And lets now save the User credential in WinJS.Application.sessionState in the click event of the Login button
var name = document.getElementById("userName").value; var password = document.getElementById("userPassword").value; WinJS.Application.sessionState.nameData = name; WinJS.Application.sessionState.passwordData = password ; WinJS.Navigation.navigate("/pages/Details.html");
In this way we can store the user UserName and password in the WinJS.Application.sessionState