2

I have a php session value like this,

$_SESSION['variable'] = "value"; 

How to access this session value in Joomla admin?

This session value is stored in PHP file and not in Joomla front end (php file created within public_html).

I thought the question is not clear may be, Simply set session in php using $_SESSION and get in joomla using either $_SESSION or getSession() method.

Joomla files and php files are in the same public_html, other than there is no common for these 2 files.

Can anyone please help me.

1 Answer 1

2

Firstly, make sure you are setting this variable using the Joomla API rather than the PHP native session handler. This will ensure the session value, along with all other Joomla session value are stored in the same place.

You can set the session variable like so:

$session = JFactory::getSession(); $session->set('variable', 'value'); 

and easily access it like so:

$session = JFactory::getSession(); $session->get('variable'); 
3
  • Thanks for your response. But session variable stored from php class file not from joomla. If I add this code in my php file it is not working. Commented Apr 9, 2018 at 10:33
  • 1
    In which case you need to call the Joomla framework on your custom PHP file before being able to use the methods Commented Apr 9, 2018 at 11:05
  • A input given by user, I want to get these details by using session. (By using file and database it is working) Commented Apr 9, 2018 at 11:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.