JSESSION-CLEAR-001
$session->clear('mynamespace')
JSession::clear($key) now clears everything
In Joomla 4, clear() is not “clear this key”. Namespaced get/set is also deprecated. People think they logged out one value and they wiped the session.
$session->clear('mynamespace') → $session->remove($key)
Symptoms people search
users logged out randomly · cart emptied · session namespace
Replace this code
Swap $session->clear('mynamespace') for $session->remove($key).
Joomla 3
Remove or stop calling this
$session->clear('com_lms');
$session->get('foo', null, 'com_lms');Joomla 4 / 6
Use this instead
$session->remove('com_lms.foo');
// Do not pass a namespace argument to get/set.How to fix it
- 1Use remove() for one key.
- 2Prefix keys yourself instead of the old namespace argument.
Also known as
Session::clear · session namespace
Related issues
- Joomla 3 → 4Joomla API
JRequest::getVar() and the whole JRequest API
JRequest::getVar() → $app->getInput()->get('id')
- Joomla 3 → 4Joomla API
JError / JException
JError::raiseError() → throw new RuntimeException() / try-catch
- Joomla 3 → 4Joomla API
isAdmin() / isSite()
$app->isAdmin() → $app->isClient('administrator') / isClient('site')
- Joomla 3 → 4Joomla API
Factory::getUri()
JFactory::getUri() → Uri::getInstance()
- Joomla 3 → 4Joomla API
Factory::getXml() / JXMLElement
JFactory::getXML() → SimpleXMLElement
- Joomla 3 → 4Joomla API
Factory::getEditor()
JFactory::getEditor() → Editor::getInstance()