ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Get session data in PHP

nry22 21 Jun, 2017
I may be missing something obvious, but I can't pull the session data into PHP using the obvious:

$var = $this->data['session_name'];

$var = $this->data['session_name']['var'];

$var = $this->var['session_name'];

(and a few other variations)

I can get the session data using {session:session_name.var} but wanted to use the data in a PHP if query - and it looks like it doesn't populate the {} content till afterwards.

Or is this not built in, and I have to pull the data using regular PHP?

Many thanks,

Nicholas.
Max_admin 21 Jun, 2017
Answer
2 Likes
Hi Nicholas,

You can use the following code in PHP:
\GApp::session()->get("session_name.var", "default");

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
nry22 21 Jun, 2017
1 Likes
That's perfect! Thank you.
tshirley 07 Jul, 2018
Hello,

I tried this, using :
$mydata = \GApp::session()->get("session_name.var", "default");
And it gave me $mydata = "default". I set the "session_name" to the name of the session set in the Save to Session action.

What am I doing wrong here?

Cheers

Tim
healyhatman 08 Aug, 2018
Did you replace ".var" with the variable you were after?
tshirley 08 Aug, 2018
Yep, that worked.

Thanks heaps. I was previously expecting that I would recover the entire data array and have to decode it, so I didn't consider changing to try to select only one variable.

So now I am off and running.

Cheers

Tim
healyhatman 08 Aug, 2018
You CAN get the whole array if you want.
$sessiondata = \GApp::session()->get("session_name", "");

And then you can use $sessiondata["variable"];
tshirley 08 Aug, 2018
Yes, that works too🙂

Thanks again

Tim
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com