Skip to content

Instantly share code, notes, and snippets.

@oscarfroberg
Forked from aaronsw/browserid.js
Created March 4, 2012 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarfroberg/1974865 to your computer and use it in GitHub Desktop.
Save oscarfroberg/1974865 to your computer and use it in GitHub Desktop.
Basic browserid functions for serverside use
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function browserid_login_callback(assertion){
setCookie('browserid_assertion', assertion, 90);
window.location.reload();
}
function browserid_login(){
navigator.id.getVerifiedEmail(browserid_login_callback);
}
function browserid_logout(){
setCookie('browserid_assertion', 'x', -30);
window.location.reload()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment