From f09e5a36d2d1e97bb80e6e9d976aac1f82b3fad8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 Apr 2012 13:21:52 -0400 Subject: [PATCH] Fix SessionComponent::id() not returning the id. When reading the id() with SessionComponent, the session should auto start, otherwise you could get null back. This makes the return more consistent. Fixes #2749 --- lib/Cake/Controller/Component/SessionComponent.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 21e6603e7..ed42bff24 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -162,15 +162,19 @@ class SessionComponent extends Component { } /** - * Returns Session id + * Get/Set the session id. * - * If $id is passed in a beforeFilter, the Session will be started - * with the specified id + * When fetching the session id, the session will be started + * if it has not already been started. When setting the session id, + * the session will not be started. * - * @param string $id - * @return string + * @param string $id Id to use (optional) + * @return string The current session id. */ public function id($id = null) { + if (empty($id)) { + CakeSession::start(); + } return CakeSession::id($id); }