Added the performance of session status judgment in php5.4.

Source: Internet
Author: User
In php5.4, the new function for judging session Status & nbsp; in previous php versions, to determine whether a session is valid, you can only use the following method: session_start (); if (isset ($ _ SESSION) {echoStarted;} else {echoNotStarted;} & nbs php 5.4 adds the session status judgment function
In previous php versions, you can only use the following method to determine whether the session is valid:
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:
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";  }


As you can see, the returned value of the int type by using session_status () indicates the various statuses of the session, such as disable (PHP_SESSION_DISABLED). The session does not exist.
(PHP_SESSION_NONE)
Or the session has been established (PHP_SESSION_ACTIVE)

1 floor lijichao 2012-02-20

2 floor mailangel123

This can be.

3 Floor mailangel123 2012-02-21

[Color = red] [/color]

[/Align] [/size] [align = center]

[/Align] [align = right]

[Size = x-small] [align = left] [/align]

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.