Hi,
I’m trying to set some session variables as part of my application, but I’m not sure how to do it using the documentParser object. I read something about not being able to set session variables the usual PHP way, but the modx evo documentation I’ve seen doesn’t explain how to set session variables.
I’m quite lost at this point, any help would be greatly appreciated.
-
☆ A M B ☆
- 24,524 Posts
I’ve never done it with Revo, but with Evo you just use the usual PHP session functions. You can get the session_name from the config.inc.php file; it’s automatically generated at installation. As long as you use snippets or other MODx elements for your code the session will be already started by the parser.
I have worked with changing sessions using the session_name from the config.inc.php file and the PHP session functions to save the MODx session, start my own and manipulate it, then restore the MODx session.
The Vanilla (forum) Single-Sign-On module needs a logged-in user’s data; it requests a site page with only the required data. I use a snippet in a resource with no template, and the snippet grabs the info from the SESSION. Since the user is logged in to MODx before going to Vanilla, and it’s the same domain, the MODx page Vanilla requests is using the same cookie/session combination, so the SESSION is set as if the user had requested the page.