Skip to content

Instantly share code, notes, and snippets.

@ianbarber
Created July 29, 2013 14:20
Show Gist options
  • Save ianbarber/6104617 to your computer and use it in GitHub Desktop.
Save ianbarber/6104617 to your computer and use it in GitHub Desktop.
Check Session State example
<html><head>
<title>checkSessionState Example</title>
<script>
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=OnLoadCallback';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
function OnLoadCallback() {
sessionParams = {
'client_id': 'YOUR_CLIENT_ID_HERE',
'session_state': null
};
gapi.auth.checkSessionState(sessionParams, function(stateMatched) {
if (stateMatched == true) {
document.getElementById("msg").textContent = "You be logged out";
} else {
document.getElementById("msg").textContent = "You be logged in";
}
});
}
</script>
</head>
<body>
<div id="msg"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment