Load Joomla framework to get access to Joomla functions using PHP

You need access to for Joomla functions via PHP?
Just include the following code into your PHP script.
Don’t forget to set the correct paths to the framework files.

define( '_JEXEC', 1 );

define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));

require_once ( JPATH_BASE. '/includes/defines.php' );

require_once ( JPATH_BASE. '/includes/framework.php' );

$mainframe = JFactory::getApplication('site');



For example: now you can access the Joomla session:


 $session = JFactory::getSession();


Set a session variable:

$session->set('var', 'content');


Get a session variable:



Clear a session variable: