mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Create _setPath() and _setHost to simplify startup.
This commit is contained in:
parent
4b65ebd64f
commit
725bfc3e12
1 changed files with 36 additions and 16 deletions
|
@ -142,22 +142,8 @@ class CakeSession {
|
||||||
|
|
||||||
self::_setupDatabase();
|
self::_setupDatabase();
|
||||||
if ($start === true) {
|
if ($start === true) {
|
||||||
if (empty($base)) {
|
self::_setPath($base);
|
||||||
self::$path = '/';
|
self::_setHost();
|
||||||
} else {
|
|
||||||
self::$path = $base;
|
|
||||||
if (strpos($base, 'index.php') !== false) {
|
|
||||||
self::$path = str_replace('index.php', '', $base);
|
|
||||||
}
|
|
||||||
if (strpos($base, '?') !== false) {
|
|
||||||
self::$path = str_replace('?', '', $base);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self::$host = env('HTTP_HOST');
|
|
||||||
|
|
||||||
if (strpos(self::$host, ':') !== false) {
|
|
||||||
self::$host = substr(self::$host, 0, strpos(self::$host, ':'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($_SESSION) || $start === true) {
|
if (isset($_SESSION) || $start === true) {
|
||||||
self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
||||||
|
@ -165,6 +151,40 @@ class CakeSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the Path variable
|
||||||
|
*
|
||||||
|
* @param string $base base path
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function _setPath($base = null) {
|
||||||
|
if (empty($base)) {
|
||||||
|
self::$path = '/';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$path = $base;
|
||||||
|
if (strpos($base, 'index.php') !== false) {
|
||||||
|
self::$path = str_replace('index.php', '', $base);
|
||||||
|
}
|
||||||
|
if (strpos($base, '?') !== false) {
|
||||||
|
self::$path = str_replace('?', '', $base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the host
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function _setHost() {
|
||||||
|
self::$host = env('HTTP_HOST');
|
||||||
|
|
||||||
|
if (strpos(self::$host, ':') !== false) {
|
||||||
|
self::$host = substr(self::$host, 0, strpos(self::$host, ':'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup database configuration for Session, if enabled.
|
* Setup database configuration for Session, if enabled.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue