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

session class: inconsistency on get() between document and code #330

Closed
takekoshinet opened this issue Dec 19, 2016 · 2 comments
Closed

Comments

@takekoshinet
Copy link
Contributor

on the document:
https://github.com/bcit-ci/CodeIgniter4/blob/develop/user_guide_src/source/libraries/sessions.rst

.. important:: The get() method WILL return flashdata items.

and

.. important:: The get() method will NOT return tempdata items.

on the source code:
https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Session/Session.php#L432

		$userdata = [];
		$_exclude = array_merge(
				['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys()
		);


		foreach (array_keys($_SESSION) as $key)
		{
			if (! in_array($key, $_exclude, true))
			{
				$userdata[$key] = $_SESSION[$key];
			}
		}
		return $userdata;

There are any wrong. Perhaps, the first.

@lonnieezell
Copy link
Member

Good catch. It turns out that when retrieving either flashdata or tempdata with a key in the the get() method, it WILL return it since it's just pulling the value directly from $_SESSION. However, if you're using get() to retrieve ALL userdata from the session, it won't include them. A little confusing, but I've clarified the docs on this point.

@takekoshinet
Copy link
Contributor Author

All right. Thank you for fixing it.

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

No branches or pull requests

2 participants