Skip to content

Instantly share code, notes, and snippets.

@mbabker

mbabker/bad.php Secret

Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbabker/f79242fd1afccf1ca645 to your computer and use it in GitHub Desktop.
Save mbabker/f79242fd1afccf1ca645 to your computer and use it in GitHub Desktop.
Using https://github.com/joomla/joomla-cms/pull/5088 as a starting point, the JSessionHandlerJoomla method that does not read from JInputCookie works as expected on PHP 7 however the method using JInputCookie always fails to correctly start a session.
public function start()
{
$session_name = $this->getName();
// Get the JInputCookie object
$cookie = $this->input->cookie;
if (is_null($cookie->get($session_name)))
{
$session_clean = $this->input->get($session_name, false, 'string');
if ($session_clean)
{
$this->setId($session_clean);
$cookie->set($session_name, '', time() - 3600);
}
}
return parent::start();
}
public function start()
{
$session_name = $this->getName();
if (isset($_COOKIE[$session_name]) && is_null($_COOKIE[$session_name]))
{
$session_clean = $this->input->get($session_name, false, 'string');
if ($session_clean)
{
$this->setId($session_clean);
setcookie($session_name, '', time() - 3600);
}
}
return parent::start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment