Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Session::get('key') returns null when value is (int) 0 #2339

Merged
merged 1 commit into from
Oct 17, 2019
Merged

Fix Session::get('key') returns null when value is (int) 0 #2339

merged 1 commit into from
Oct 17, 2019

Conversation

dafriend
Copy link
Contributor

Issue #2334

Description
The code in question is from Session.php starting at line #499

if (! empty($key) && $value = dot_array_search($key, $_SESSION))
{
    return $value;
}

When dot_array_search() returns a value of 0 (zero) then $value is evaluated as false so $value is not returned eventhough it should be.

Proposed fix: change the conditional to

if (! empty($key) && ! is_null($value = dot_array_search($key, $_SESSION)))

A unit test added to confirm this works.

@lonnieezell lonnieezell merged commit 938176f into codeigniter4:develop Oct 17, 2019
@dafriend dafriend deleted the session_returns_null_with_zero_value branch October 17, 2019 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants