PHP 5.4 adds the function of judging session status

巴扎黑
Release: 2016-11-23 15:17:38
Original
1029 people have browsed it

In previous php versions, to determine whether the session is valid, you can only use the following method:

Java code

session_start();

if(isset($_SESSION))

{

echo "Started";

}

else

{

echo "Not Started";

}

In php 5.4 (forthcoming), the status of the session is To subdivide, you can use the following Method judgment:


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" ;

}

You can see that by using session_status(), an int type value is returned, indicating various statuses of the session, such as prohibited (PHP_SESSION_DISABLED), session does not exist yet

(PHP_SESSION_NONE)

, Or the session has been established (PHP_SESSION_ACTIVE)



Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!