Skip to content
Permalink
Browse files

Initial fixes for failing session tests

  • Loading branch information...
phpnut committed Dec 28, 2015
1 parent 1fd3293 commit 5c3bc44ef5c3cffb648352203feee762418442a5
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/Cake/Model/Datasource/CakeSession.php
@@ -218,7 +218,7 @@ public static function start() {
* @return bool True if session has been 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 @@ public static function destroy() {
}
if (static::started()) {
if(session_id() && isset($_SESSION)){
session_write_close();
}
session_start();
session_destroy();
if (isset($_COOKIE[static::_cookieName()])){
unset($_COOKIE[static::_cookieName()]);
}
}
$_SESSION = null;
@@ -753,7 +760,11 @@ public static function renew() {
if (isset($_COOKIE[session_name()])) {
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);
}
}
/**

0 comments on commit 5c3bc44

Please sign in to comment.
You can’t perform that action at this time.