If PHP is stateless then even if you declare variables as static they do not retain their values across different runs. So is it pointless to try and monitor your sessions using a class such as below as sessions maintain state across runs but PHP user code does not.
class session
{
protected static $ses_id ="";
public static function start()
{
self::$ses_id = session_start();
}
public static function is_start()
{
return self::$ses_id;
}
public static function finish()
{
self::$ses_id = 0;
$_SESSION=array();
if (session_id() != "" || isset($_COOKIE[session_name()]))
{
setcookie(session_name(), '', time()-2592000, '/');
}
session_destroy();
}
}
Your class as you’ve written it doesn’t add any new functionality, it simply wraps existing functionality (provided by the
session_*functions). This kind of thing can be worthwhile if you need to mediate or control access to the session. Only you can judge whether it’s worthwhile in your own app.