Exemplo n.º 1
0
 public static function session_start($sess_name = false)
 {
     if (!$sess_name) {
         $sess_name = Xcrud_config::$sess_name;
     }
     if (!session_id() && !Xcrud_config::$external_session && !Xcrud_config::$alt_session) {
         if (!headers_sent()) {
             session_name($sess_name);
             session_cache_expire(Xcrud_config::$sess_expire);
             session_set_cookie_params(0, '/');
             session_start();
         } else {
             self::error('xCRUD can not create session, because the output is already sent into browser. 
             Try to define xCRUD instance before the output start or use session_start() at the beginning of your script');
         }
     }
     if (Xcrud_config::$alt_session) {
         if (!headers_sent()) {
             if (!isset($_COOKIE[$sess_name])) {
                 self::$sess_id = base_convert(str_replace(' ', '', microtime()) . rand(), 10, 36);
             } else {
                 self::$sess_id = $_COOKIE[$sess_name];
             }
             setcookie($sess_name, self::$sess_id, time() + Xcrud_config::$alt_lifetime * 60, '/');
         } else {
             self::error('xCRUD can not start session, because the output is already sent into browser. 
             Try to define xCRUD instance before the output start or use <strong>Xcrud::session_start();</strong> at the beginning of your script');
         }
     }
 }