Identity/Verified Email Protocol/Latest-Session
Jump to navigation
Jump to search
So you want to implement the Session API. Great! Unfortunately our documentation isn't very good yet, but here's a short block of code which shows all of the API:
// All logic needs to be wrapped in the if(navigator.id) block so that we do not break // non-supporting browsers. if(navigator.id) { // indicate support - for before the user is logged in. navigator.id.sessions = []; // user logged in, no cookies - for once the user is logged in. navigator.id.sessions = [{ email: "user@foo.com" }]; // user logged in, bound to cookie named SID - for once the user is logged in. navigator.id.sessions = [{ email: "user@foo.com", bound_to: { type: "cookie", cookie_name: "SID" } }]; // login/logout events are triggered on document when the user clicks the appropriate button. document.addEventListener("login", function(event) { // redirect to login page document.location.href = ...; }, false); document.addEventListener("logout", function(event) { // redirect to logout page document.location.href = ...; }, false); }