Skip to content

Instantly share code, notes, and snippets.

@ridoansaleh
Created December 2, 2017 09:13
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 ridoansaleh/29e8a83fcb8a4d387d3aec189f0957b7 to your computer and use it in GitHub Desktop.
Save ridoansaleh/29e8a83fcb8a4d387d3aec189f0957b7 to your computer and use it in GitHub Desktop.
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Session 2</title>
</head>
<body>
<?php
if(isset($_SESSION['login'])){
echo "Selamat datang, <b>".$_SESSION['login']."</b>.";
echo "<h2>Halaman Session 2</h2>";
echo "<a href='index.php' onclick='Logout()'>Logout</a>";
}else{
echo "Kamu belum login";
echo "<br> Silahkan <a href='index.php'>login</a> dahulu.";
}
?>
<script type="text/javascript">
function Logout(){
<?php
session_destroy();
?>
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment