Home > Backend Development > PHP Tutorial > PHP 5.4 adds the function of judging session status

PHP 5.4 adds the function of judging session status

巴扎黑
Release: 2016-11-23 15:17:38
Original
1130 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
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template