Initial fixes for failing session tests

This commit is contained in:
Larry E. Masters 2015-12-28 11:41:23 -05:00
parent 1fd329311b
commit 5c3bc44ef5

View file

@ -218,7 +218,7 @@ class CakeSession {
* @return bool True if session has been started. * @return bool True if session has been started.
*/ */
public static function started() { public static function started() {
return isset($_SESSION) && session_id(); return (isset($_SESSION) && session_id()) || isset($_SESSION) && (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg');
} }
/** /**
@ -461,7 +461,14 @@ class CakeSession {
} }
if (static::started()) { if (static::started()) {
if(session_id() && isset($_SESSION)){
session_write_close();
}
session_start();
session_destroy(); session_destroy();
if (isset($_COOKIE[static::_cookieName()])){
unset($_COOKIE[static::_cookieName()]);
}
} }
$_SESSION = null; $_SESSION = null;
@ -753,7 +760,11 @@ class CakeSession {
if (isset($_COOKIE[session_name()])) { if (isset($_COOKIE[session_name()])) {
setcookie(Configure::read('Session.cookie'), '', time() - 42000, static::$path); setcookie(Configure::read('Session.cookie'), '', time() - 42000, static::$path);
} }
session_regenerate_id(true); if (!headers_sent()){
session_write_close();
session_start();
session_regenerate_id(true);
}
} }
/** /**