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.
$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.
Hi Nicholas,
You can use the following code in PHP:
Best regards,
Max
You can use the following code in PHP:
\GApp::session()->get("session_name.var", "default");
Best regards,
Max
Hello,
I tried this, using :
What am I doing wrong here?
Cheers
Tim
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
Did you replace ".var" with the variable you were after?
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
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
You CAN get the whole array if you want.
And then you can use $sessiondata["variable"];
$sessiondata = \GApp::session()->get("session_name", "");
And then you can use $sessiondata["variable"];
This topic is locked and no more replies can be posted.