My suggestion is to use local storage
over session
and cookies
as session is different for every tab in the browser and cookies are have sessions(time to get deleted). Local storage values stay there until someone delete them. For simplicity, we use plain javascript code to access local storage in angularjs.
Coming to your question, on user login store user id, and password in local storage of the browser.
For example, we can call like this directly in a angularjs controller
localStorage.setItem(key, value)
// to store a value
localStorage.setItem(key, JSON.stringify(value))
// to store an object
localStorage.getItem(key)
// to retrieve value
JSON.parse(localStorage.getItem(key))
// to retrieve an object
examples as per your requirement,
localStorage.setItem('userId', userId)
var user = localStorage.getItem('userId')
if(user){ //if user already logged in
// retrieve user relevant data from DB, show home page directly or whatever you want.
}
I think there will be security risk if you store selected items in local storage. But if you want to store them as well, just store them on selecting confirmation.
localStorage.setItem('selectedItems', JSON.stringify(selectedItems))
I assumed selectedItems
as an object. Retrieve them based on your requirement.