Optimize renew().

Don't call session_id() twice when we can use a local variable to store
the current session id.

Fixes #3531
This commit is contained in:
mark_story 2014-05-22 14:28:56 -04:00
parent c6d02d5779
commit 81875cfeb1

View file

@ -713,13 +713,15 @@ class CakeSession {
* @return void * @return void
*/ */
public static function renew() { public static function renew() {
if (session_id()) { $id = session_id();
if (session_id() || isset($_COOKIE[session_name()])) { if (!$id) {
return;
}
if ($id || isset($_COOKIE[session_name()])) {
setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path); setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path);
} }
session_regenerate_id(true); session_regenerate_id(true);
} }
}
/** /**
* Helper method to set an internal error message. * Helper method to set an internal error message.