/**
  * Generates Session ID
  *
  * Generates a session ID to use. Checks existing sessions to avoid conflict.
  *
  * @return string
  */
 public static function generateSID()
 {
     $key = null;
     while (Session::isSession($key) || $key === null) {
         $key = sha1(time() . '-' . microtime(true) . '-' . rand(0, PHP_INT_MAX) . filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'));
     }
     return $key;
 }