What are the Real Integers of Session Status

What are the real integers represented by the session status constants PHP_SESSION_DISABLED, PHP_SESSION_NONE and PHP_SESSION_ACTIVE? A simple test can tell us the truth.

<?php
echo PHP_SESSION_DISABLED . ": PHP_SESSION_DISABLED";
echo " - if sessions are disabled" . "<br />";
echo PHP_SESSION_NONE . ": PHP_SESSION_NONE";
echo " - if sessions are enabled, but none exists." . "<br />";
echo PHP_SESSION_ACTIVE . ": PHP_SESSION_ACTIVE";
echo " - if sessions are enabled, and one exists." . "<br />";
?>

The result is as follow:

0: PHP_SESSION_DISABLED - if sessions are disabled
1: PHP_SESSION_NONE - if sessions are enabled, but none exists.
2: PHP_SESSION_ACTIVE - if sessions are enabled, and one exists.

Developers can use the above constants since PHP 5.4.

Leave a Reply

Your email address will not be published. Required fields are marked *