In php5.4, the new function for judging session status was added. in the previous php version, to determine whether the session is valid, you can only use the following method :? Java code ?? Session_start ();???????? If (isset ($ _ SESSION ))???? {??????? Echo? "Added the session status judgment function in php 5.4.
In previous php versions, you can only use the following method to determine whether the session is valid :?
Java code ??
- Session_start ();??
- ????
- ?? If (isset ($ _ SESSION ))??
- ?? {???
- ???? Echo? "Started ";??
- ??}??
- ?? Else ??
- ?? {??
- ???? Echo? "Not? Started ";??
- ??}??
?? In php 5.4 (coming soon), the session status is subdivided and can be determined using the following method :?
Java code ??
- Session_start ();??
- ????
- ?? $ Status? =? Session_status ();??
- ????
- ?? If ($ status? ==? PHP_SESSION_DISABLED )??
- ?? {??
- ???? Echo? "Session? Is? Disabled ";??
- ??}??
- ?? Else? If ($ status? ==? PHP_SESSION_NONE ?)??
- ?? {??
- ???? Echo? "Session? Enabled? But? No? Session? Values? Created ";??
- ??}??
- ?? Else ??
- ?? {??
- ???? Echo? "Session? Enabled? And? Session? Values? Created ";??
- ??}??
? We can see that the result returned by using session_status () is an int type value, indicating the various statuses of the session, such as disabling (PHP_SESSION_DISABLED). Does the session still exist?
(PHP_SESSION_NONE )?
Or the session has been established (PHP_SESSION_ACTIVE )?