Navigation Menu

Skip to content

Commit

Permalink
Fix SessionComponent::id() not returning the id.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markstory committed Apr 3, 2012
1 parent 7ed90c7 commit f09e5a3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/Cake/Controller/Component/SessionComponent.php
Expand Up @@ -162,15 +162,19 @@ public function destroy() {
}

/**
* 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);
}

Expand Down

0 comments on commit f09e5a3

Please sign in to comment.