From 81875cfeb1b8e5c414cf9de3c96dd2dde50150bc Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 22 May 2014 14:28:56 -0400 Subject: [PATCH] Optimize renew(). Don't call session_id() twice when we can use a local variable to store the current session id. Fixes #3531 --- lib/Cake/Model/Datasource/CakeSession.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 1721824f1..17fbeedd2 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -713,12 +713,14 @@ class CakeSession { * @return void */ public static function renew() { - if (session_id()) { - if (session_id() || isset($_COOKIE[session_name()])) { - setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path); - } - session_regenerate_id(true); + $id = session_id(); + if (!$id) { + return; } + if ($id || isset($_COOKIE[session_name()])) { + setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path); + } + session_regenerate_id(true); } /**