PHP Session judgment: New additions to session state judgment in PHP 5.4

Source: Internet
Author: User

In previous versions of PHP, to determine if the session was valid, you could only use the following methods:
Session_Start ();
if (Isset ($_session))
{
echo "Started";
}
Else
{
echo "Not Started";
}
In PHP 5.4 (forthcoming release), the state of the session is subdivided, you can use the following methods to determine:
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";
}
You can see that by using Session_status () you return a value of type int, indicating the various states of the session, such as the Prohibition (php_session_disabled), which does not exist
(Php_session_none)
, or the session has been set up (php_session_active) This article links http://www.cxybl.com/html/wlbc/Php/20120607/28693.html

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.