mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +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;
|
||||
|
||||
/**
|
||||
* Whether or not the init function in this class was already called
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected static $_initialized = false;
|
||||
|
||||
/**
|
||||
* Pseudo constructor.
|
||||
*
|
||||
|
@ -130,15 +137,20 @@ class CakeSession {
|
|||
*/
|
||||
public static function init($base = null) {
|
||||
self::$time = time();
|
||||
|
||||
$checkAgent = Configure::read('Session.checkAgent');
|
||||
|
||||
if (env('HTTP_USER_AGENT')) {
|
||||
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
||||
}
|
||||
|
||||
self::_setPath($base);
|
||||
self::_setHost(env('HTTP_HOST'));
|
||||
|
||||
register_shutdown_function('session_write_close');
|
||||
if (!self::$_initialized) {
|
||||
register_shutdown_function('session_write_close');
|
||||
}
|
||||
|
||||
self::$_initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,10 +195,8 @@ class CakeSession {
|
|||
if (self::started()) {
|
||||
return true;
|
||||
}
|
||||
self::init();
|
||||
|
||||
$id = self::id();
|
||||
session_write_close();
|
||||
self::_configureSession();
|
||||
self::_startSession();
|
||||
|
||||
if (!$id && self::started()) {
|
||||
|
@ -607,6 +617,10 @@ class CakeSession {
|
|||
* @return boolean Success
|
||||
*/
|
||||
protected static function _startSession() {
|
||||
self::init();
|
||||
session_write_close();
|
||||
self::_configureSession();
|
||||
|
||||
if (headers_sent()) {
|
||||
if (empty($_SESSION)) {
|
||||
$_SESSION = array();
|
||||
|
|
Loading…
Reference in a new issue