JFACTORY-GETSESSION-001
JFactory::getSession()
Factory::getSession()
Session is an application service, not a Factory shortcut.
JFactory::getSession() → $app->getSession()
What you will see
- Factory::getSession is deprecated
Symptoms people search
session lost after upgrade · clear() wiped whole session
Replace this code
Swap JFactory::getSession() for $app->getSession().
Joomla 3
Remove or stop calling this
$session = JFactory::getSession();
$session->set('foo', 1);Joomla 4 / 6
Use this instead
$session = Factory::getApplication()->getSession();How to fix it
- 1Use $app->getSession().
- 2Replace Session::clear($key) with remove($key) — clear() now clears everything.
Also known as
getSession
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()