Skip to content

Instantly share code, notes, and snippets.

@makzan
Created September 29, 2017 12:52
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 makzan/3392eb251008e51baa9b223e67b9dfea to your computer and use it in GitHub Desktop.
Save makzan/3392eb251008e51baa9b223e67b9dfea to your computer and use it in GitHub Desktop.
Test PHP $_SESSION
<?php
session_id("thomas23");
session_start();
if (!isset($_SESSION["q_num"]) ){
$_SESSION["q_num"] = 0;
}
if (count($_POST) > 0) {
$_SESSION["q_num"] += 1;
}
$q_num = $_SESSION["q_num"];
?>
<form action="" method="POST">
<?= $q_num ?>
<input type="submit" name="anything" value="Count +1">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment