//On page 1 $_SESSION['varname'] = $var_value; //On page 2 $var_value = $_SESSION['varname']; w3school code example

Example 1: destroy session php

<?php 
 session_start(); // start session
 session_destroy();  // Delete whole session
// OR
unset($_SESSION['username']); // delete any specific session only
?>

Example 2: create session in php

<?php 
  // Start the session
  session_start();

  // Set session variables
  $_SESSION["color"]= "blue";
  $_SESSION["animal"]= "dog";
  echo "The session variable are set up.";
?>

Tags:

Php Example