mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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
This commit is contained in:
parent
7ed90c72ae
commit
f09e5a36d2
1 changed files with 9 additions and 5 deletions
|
@ -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
|
* When fetching the session id, the session will be started
|
||||||
* with the specified id
|
* if it has not already been started. When setting the session id,
|
||||||
|
* the session will not be started.
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id Id to use (optional)
|
||||||
* @return string
|
* @return string The current session id.
|
||||||
*/
|
*/
|
||||||
public function id($id = null) {
|
public function id($id = null) {
|
||||||
|
if (empty($id)) {
|
||||||
|
CakeSession::start();
|
||||||
|
}
|
||||||
return CakeSession::id($id);
|
return CakeSession::id($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue