php 5.4中新增加对session状态判断的功能
在以前的php 版本中,要判断session是否有效,只能用如下的方法:
session_start(); if(isset($_SESSION)) { echo "Started"; } else { echo "Not Started"; }
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"; }