2

I am using Modx Evo 1.0.4 and attempting to retrieve values via an API and store them to a modx session variable. It's a user login. Once login credentials are sent the next page calls print_r($_SESSION); However, an empty array is printed. If I refresh this page, the array with loaded session variables is shown.

I'm creating the session here:

require_once '../manager/includes/config.inc.php';
startCMSSession();
$_SESSION['mx_iCode'] = "test";//$_SESSION['iCode'];
$_SESSION['mx_firstName']= $_SESSION['firstName'];
$_SESSION['mx_lastName']= $_SESSION['lastName'];
$_SESSION['mx_address'] = $_SESSION['address1'].' '.$_SESSION['address2'].'       .$_SESSION['address3'];
$_SESSION['mx_city'] = $_SESSION['city'];
$_SESSION['mx_state'] = $_SESSION['stProvince'];
$_SESSION['mx_zip'] = $_SESSION['postalCode'];

and printing it to the page it's posted to using:

print_r($_SESSION);

I've tried adjusting the cache options on the "print_r" page in modX but every option yields the same results...which is it only lists the Session variables after I refresh the page.

Is the delayed a result of storing external sessions to modX sessions?

bfncs
  • 10,007
  • 4
  • 32
  • 52
mcmonty
  • 83
  • 1
  • 9

1 Answers1

1

SOLVED! Finally.

On my external page, I called

session_start();

to process some other data. I added

startCMSSession();

before the values I needed to access in the snippet. Getting rid of session_start() altogether fixed the issue.

DO NOT USE session_start() anywhere on the page with startCMSSession().

mcmonty
  • 83
  • 1
  • 9