mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Ensuring session is configured before trying to destory it
This commit is contained in:
parent
848a0ce217
commit
70d5c37834
1 changed files with 19 additions and 5 deletions
|
@ -122,6 +122,13 @@ class CakeSession {
|
||||||
*/
|
*/
|
||||||
public static $requestCountdown = 10;
|
public static $requestCountdown = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the init function in this class was already called
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $_initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pseudo constructor.
|
* Pseudo constructor.
|
||||||
*
|
*
|
||||||
|
@ -130,17 +137,22 @@ class CakeSession {
|
||||||
*/
|
*/
|
||||||
public static function init($base = null) {
|
public static function init($base = null) {
|
||||||
self::$time = time();
|
self::$time = time();
|
||||||
|
|
||||||
$checkAgent = Configure::read('Session.checkAgent');
|
$checkAgent = Configure::read('Session.checkAgent');
|
||||||
|
|
||||||
if (env('HTTP_USER_AGENT')) {
|
if (env('HTTP_USER_AGENT')) {
|
||||||
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::_setPath($base);
|
self::_setPath($base);
|
||||||
self::_setHost(env('HTTP_HOST'));
|
self::_setHost(env('HTTP_HOST'));
|
||||||
|
|
||||||
|
if (!self::$_initialized) {
|
||||||
register_shutdown_function('session_write_close');
|
register_shutdown_function('session_write_close');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the Path variable
|
* Setup the Path variable
|
||||||
*
|
*
|
||||||
|
@ -183,10 +195,8 @@ class CakeSession {
|
||||||
if (self::started()) {
|
if (self::started()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
self::init();
|
|
||||||
$id = self::id();
|
$id = self::id();
|
||||||
session_write_close();
|
|
||||||
self::_configureSession();
|
|
||||||
self::_startSession();
|
self::_startSession();
|
||||||
|
|
||||||
if (!$id && self::started()) {
|
if (!$id && self::started()) {
|
||||||
|
@ -607,6 +617,10 @@ class CakeSession {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
protected static function _startSession() {
|
protected static function _startSession() {
|
||||||
|
self::init();
|
||||||
|
session_write_close();
|
||||||
|
self::_configureSession();
|
||||||
|
|
||||||
if (headers_sent()) {
|
if (headers_sent()) {
|
||||||
if (empty($_SESSION)) {
|
if (empty($_SESSION)) {
|
||||||
$_SESSION = array();
|
$_SESSION = array();
|
||||||
|
|
Loading…
Reference in a new issue