/** * Set a suffix for all URLs that will be generated with this class. * @method suffix * @static * @param {array|string} [$suffix=null] If no arguments are passed, just returns the current suffix. * Pass an array here. For each entry, the key is tested and if it * begins the URL, then the value is appended. * Suffixes are applied when URLs are generated. * You can also pass a string here, in which case the array('' => $suffix) is used. * @return {array} Returns the suffix at the time the function was called. */ static function suffix($suffix = null) { if (is_string($suffix)) { $suffix = array('' => $suffix); } if (!isset($suffix)) { return isset(self::$suffix) ? self::$suffix : array(); } $prev_suffix = self::$suffix; self::$suffix = $suffix; return $prev_suffix; }
/** * @method init * @static */ static function init() { if (self::$inited) { return false; } ini_set("session.entropy_file", "/dev/urandom"); ini_set("session.entropy_length", "512"); ini_set("session.hash_function", "1"); $base_url = Q_Request::baseUrl(); $name = Q_Config::get('Q', 'session', 'name', 'sessionId'); $lifetime = Q_Config::get('Q', 'session', 'durations', Q_Request::formFactor(), 0); $parts = parse_url($base_url); $path = !empty($parts['path']) ? $parts['path'] : '/'; $domain = '.' . $parts['host']; Q::event('Q/session/init', array('name' => &$name, 'lifetime' => &$lifetime, 'path' => &$path, 'domain' => &$domain), 'before'); Q_Session::name($name); session_set_cookie_params(isset($lifetime) ? $lifetime : 0, $path, $domain, false, false); if (Q_Config::get('Q', 'session', 'appendSuffix', false) or isset($_GET[$name])) { if (self::id()) { $s = "?{$name}=" . self::id(); $suffix = Q_Uri::suffix(); $suffix[$base_url] = isset($suffix[$base_url]) ? $suffix[$base_url] . $s : $s; Q_Uri::suffix($suffix); } } self::$inited = true; return true; }