// Get the current session object $session = JFactory::getSession(); // Get a value from the session $value = $session->get('myKey'); // Set a value in the session $session->set('myKey', 'myValue');
// Get the session ID $sessionId = JFactory::getSession()->getId(); // Output the session ID echo "Session ID: $sessionId";In this example, we obtain the current session object, get the session ID and output it. This package/library belongs to the Joomla platform. The JFactory class is part of the Joomla core and is available in all Joomla installations.