Created
October 26, 2018 12:23
-
-
Save NirmalAriyathilake/f88d463012a3fb8ede15a23e9eb1cf36 to your computer and use it in GitHub Desktop.
Double Submit Cookies Pattern - logout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
//remove PHPSESSID from browser | |
if ( isset( $_COOKIE[session_name()] ) ) | |
setcookie( session_name(), null, time()-3600, '/' ); | |
//clear session from globals | |
$_SESSION = array(); | |
//clear session from disk | |
session_destroy(); | |
$cookieName = "sessionCookie"; | |
if ( isset( $_COOKIE[$cookieName] ) ) | |
setcookie($cookieName, null, time()-3600, '/'); | |
$cookieNameCsrf = "csrfTokenCookie"; | |
if ( isset( $_COOKIE[$cookieNameCsrf] ) ) | |
setcookie($cookieNameCsrf, null, time()-3600, '/'); | |
?> | |
<html> | |
<body> | |
<script> | |
alert("You are Successfully Logged out!"); | |
window.location.href = "index.php"; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment