Google Sign in API - How do I log someone out with PHP?
This should work, I fixed the problem with Mark Guinn's code, which was the fact that the gapi.auth2.init();
method's tasks were not finished executing. .next()
'ing it solved the issue.
<?php
session_start();
session_unset();
session_destroy();
?>
<html>
<head>
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID">
</head>
<body>
<script src="https://apis.google.com/js/platform.js?onload=onLoadCallback" async defer></script>
<script>
window.onLoadCallback = function(){
gapi.load('auth2', function() {
gapi.auth2.init().then(function(){
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
document.location.href = 'login.php';
});
});
});
};
</script>
</body>
</html>