Added the session status judgment function in php5.4.

Source: Internet
Author: User
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 ??
  1. Session_start ();??
  2. ????
  3. ?? If (isset ($ _ SESSION ))??
  4. ?? {???
  5. ???? Echo? "Started ";??
  6. ??}??
  7. ?? Else ??
  8. ?? {??
  9. ???? Echo? "Not? Started ";??
  10. ??}??



?? In php 5.4 (coming soon), the session status is subdivided and can be determined using the following method :?

Java code ??
  1. Session_start ();??
  2. ????
  3. ?? $ Status? =? Session_status ();??
  4. ????
  5. ?? If ($ status? ==? PHP_SESSION_DISABLED )??
  6. ?? {??
  7. ???? Echo? "Session? Is? Disabled ";??
  8. ??}??
  9. ?? Else? If ($ status? ==? PHP_SESSION_NONE ?)??
  10. ?? {??
  11. ???? Echo? "Session? Enabled? But? No? Session? Values? Created ";??
  12. ??}??
  13. ?? Else ??
  14. ?? {??
  15. ???? Echo? "Session? Enabled? And? Session? Values? Created ";??
  16. ??}??



? 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 )?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.