6

I've been wondering this for a while now.

What are the differences between Joomla sessions and php sessions? Are they interchangeable?

2 Answers 2

6

JSession is based on the standard PHP session handling mechanism but I would not say they are interchangeable, as Joomla is directly "talking" to JSession and not to the super global.

In backend you select a session handler (the default being the database) where Joomla will store session related informations, basically it's serializing the content of $_SESSION itself.

When a cookie is sent, no actual readable data is stored, just a session identifier.

It also provides a very simple, namespaced interface to store and retrieve data from the user session. Read an entire article about this on ostraining.

2
  • 3
    "it's not storing much data in the $_SESSION itself" - Are you sure? I think all the session data is still stored in the $_SESSION superglobal, it's just that Joomla creates a custom session handler and wraps the setting/getting of $_SESSION properties with its own methods. If the data is not in $_SESSION then Joomla is doing something very non-PHP like?
    – MrWhite
    Apr 28, 2014 at 9:59
  • 1
    Thanks for your comment. Retracted the part with "it's not storing much data in the $_SESSION itself" as it was not true. Apr 30, 2014 at 17:58
3

Joomla uses the PHP session functions to create its JSession object, but it provides wrapper functions and namespaces the session to keep the data segregated. If you dump the PHP superglobal $_SESSION you will see the Joomla session items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.