Identity/Verified Email Protocol/Latest-Session
Jump to navigation
Jump to search
| Note: The Verified Email Protocol has been deprecated. Please check the BrowserID protocol. |
So you want to implement the Session API. Great! We're still working on better docs, but so far we have:
- A tutorial on Shane's blog for how to use it.
- An API doc
- The following block of code which shows off most 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);
}