Simple http session


/ Published in: PHP
Save to your folder(s)

This script helps you to test session persistence for your HTTP API.

Launch this.php?set=valuuue to set the session value stored to value.
Launch this.php to retrieve the value.


Copy this code and paste it in your HTML
  1. <?php
  2. /**
  3.  * This script helps you to test session persistence for your HTTP API
  4.  *
  5.  * launch this.php?set=valuuue to set the session value stored to value
  6.  * launch this.php to retrieve the value
  7.  */
  8.  
  9.  
  10. if (isset($_GET['set'])) {
  11. $_SESSION['value'] = $_GET['set'];
  12. echo 'value set to : '.$_SESSION['value'];
  13. } else {
  14. if (!isset($_SESSION['value'])) {
  15. echo 'no value stored';
  16. } else {
  17. echo 'session contains : '.$_SESSION['value'];
  18. }
  19. }
  20. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.