Created
May 30, 2016 09:57
-
-
Save elgamine-dev/4e231252ef32e0bf6c6aa9ec02f83449 to your computer and use it in GitHub Desktop.
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(); | |
if(isset($_POST['msg'])) { | |
$_SESSION['msg'] = htmlspecialchars($_POST['msg']); | |
} | |
if(isset($_GET['logout'])) { | |
session_destroy(); | |
} | |
function flash(){ | |
if(isset($_SESSION['msg'])) { | |
$msg = $_SESSION['msg']; | |
unset($_SESSION['msg']); | |
} | |
return $msg; | |
} | |
?><!doctype html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="apple-touch-icon" href="apple-touch-icon.png"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/components/message.css"> | |
<!-- Place favicon.ico in the root directory --> | |
<style> | |
body { | |
font-size:22px; | |
} | |
</style> | |
</head> | |
<body> | |
<?php if(isset($_SESSION['msg'])) : ?> | |
<div class="ui message"><?=flash()?></div> | |
<?php endif; ?> | |
<h1>session !</h1> | |
<form action="?" method="post"> | |
<input type="text" name="msg"> | |
<button>go</button> | |
</form> | |
<a href="?logout">Logout</a> | |
<details> | |
<h3>Session</h3> | |
<pre><code><?php var_dump($_SESSION)?></code></pre> | |
<h3>Cookie</h3> | |
<pre><code><?php var_dump($_COOKIE)?></code></pre> | |
</details> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment