public static function setCookieRaw($key, $value, $life = null, $path = '/', $domian = null, $http_only = false) { header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); if (!is_null($domian)) { $auto_domain = $domian; } else { $host = MpInput::server('HTTP_HOST'); // $_host = current(explode(":", $host)); $is_ip = preg_match('/^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/', $host); $not_regular_domain = preg_match('/^[^\\.]+$/', $host); if ($is_ip) { $auto_domain = $host; } elseif ($not_regular_domain) { $auto_domain = NULL; } else { $auto_domain = '.' . $host; } } setcookie($key, $value, $life ? $life + time() : null, $path, $auto_domain, MpInput::server('SERVER_PORT') == 443 ? 1 : 0, $http_only); $_COOKIE[$key] = $value; }
private static function checkSession() { $system = systemInfo(); $common_config = $system['session_handle']['common']; // set some important session vars ini_set('session.auto_start', 0); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', $common_config['lifetime']); ini_set('session.referer_check', ''); ini_set('session.entropy_file', '/dev/urandom'); ini_set('session.entropy_length', 16); ini_set('session.use_cookies', 1); ini_set('session.use_only_cookies', 1); ini_set('session.use_trans_sid', 0); ini_set('session.hash_function', 1); ini_set('session.hash_bits_per_character', 5); // disable client/proxy caching session_cache_limiter('nocache'); // set the cookie parameters session_set_cookie_params($common_config['lifetime'], $common_config['cookie_path'], preg_match('/^[^\\.]+$/', MpInput::server('HTTP_HOST')) ? null : $common_config['cookie_domain']); // name the session session_name($common_config['session_name']); register_shutdown_function('session_write_close'); //session自定义配置检测 if (!empty($system['session_handle']['handle']) && isset($system['session_handle'][$system['session_handle']['handle']])) { $driver = $system['session_handle']['handle']; $config = $system['session_handle']; $handle = ucfirst($driver) . 'SessionHandle'; if (class_exists($handle, FALSE)) { $session = new $handle(); $session->start($config); } } // start it up if ($common_config['autostart']) { sessionStart(); } }