isset short way [ 879 views ]
How we can check if variable is defined or if not than get a default value? The general answer is isset and ternary operator
$myVar = isset($_SESSION["variableName"]) ? $_SESSION["variableName"] : 'defaultValue';
let’s simplify this!
$myVar = isset($_SESSION["variableName"]) ?: 'defaultValue';
or after PHP 7.0.1 you can use this shorter way
$myVar = $_SESSION["variableName"] ?? 'defaultValue';