You can check whether a variable has been set in a user's session using the function isset(), as you would a normal variable. Because the $_SESSION superglobal is only initialised once session_start() has been called, you need to call session_start() before using isset() on a session variable.
Use this: echo '<pre>'; var_dump($_SESSION); echo '</pre>'; Or you can use print_r if you don't care about types.
PHP $_SESSION is an associative array that contains all session variables. It is used to set and get session variable values.
if (isset($_SESSION['errors']))
{
//Do stuff
}
use isset()
and empty()
php function.
if (isset($_SESSION['errors']) && !empty($_SESSION['errors'])) {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With