×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Сергей Шевченко
Added: Apr 8, 2017 7:49 AM
Modified: May 23, 2017 3:59 PM
Views: 17
  1. /**
  2.      * Does a session exist and is it currently active?
  3.      *
  4.      * @return bool
  5.      */
  6.     public function sessionExists()
  7.     {
  8.         if (session_status() == PHP_SESSION_ACTIVE) {
  9.             return true;
  10.         }
  11.         $sid = defined('SID') ? constant('SID') : false;
  12.         if ($sid !== false && session_id()) {
  13.             return true;
  14.         }
  15.         if (headers_sent()) {
  16.             return true;
  17.         }
  18.         return false;
  19.     }