Speed up development with full-stack environments for every branch.

Learn More

Register / Unregister session variables [PHP]

313 Runs 2140 Views 496 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php
/*
 * PHP Session - Register / Unregister session variables 
 */

//start the session
session_start();

//if not exists, ads the myvar variable into the session array
if (!isset($_SESSION['myvar']))
    $_SESSION['myvar'] = "value";

//echo the myvar session variable
echo "The myvar variable value is : ".$_SESSION['myvar'];

//unset the myvar session variable
unset($_SESSION['myvar']);
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).