Joomla – How to set and get $_SESSION variables by an external PHP-script

When you are trying to set or get $_SESSION variable in Joomla environment using standart approach from an external script, it appears to be empty or not set.

$_SESSION['variable_name'] = "test";
$test_var = $_SESSION['variable_name']; // $test_var is empty!?!

It happens because Joomla uses its own session handling with come unique session-id-generation and some encryption in place, so the only way to get into the Joomla session data is to use the appropriate Joomla functions. I recently had a project where I needed to make simple data-input form with captcha generator and the original captcha data was stored in (and then got from) session.

Continue reading