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)

Dies at Joomla 3 → 4J3: Works nativelyJ4: Changed behaviourJ6: Changed behaviourBC plugin: not applicablePatch possible — review itJoomla API

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

  1. 1Use remove() for one key.
  2. 2Prefix keys yourself instead of the old namespace argument.

Also known as

Session::clear · session namespace

Related issues

Get in touch

Have a project in mind? Let's talk about it.

Tell us what you're building. Whether it's a new site, an online store, a mobile app, or something that needs AI under the hood, we'll get back to you within a business day.

Free consultation
No commitment, no pressure
Reply within 24 hours
Usually much faster

Prefer a direct conversation?

Request a project quote

Tell us about your project

Fill out the quick form and we'll reach out.