Session Variable not being saved

I’ve called session_start() at the beggining of my script
but the following code will not set my session variable


    $parsed_xml = simplexml_load_string($response);
    $CartId = $parsed_xml->Cart->CartId;
    $HMAC = $parsed_xml->Cart->URLEncodedHMAC;
    echo $CartId;
    echo '<BR>' . $HMAC;
    $_SESSION ['cart'] = $CartId;

the echo’s will return the results I want but assigning the variable to my session variable doesn’t work

I can change it to:


$_SESSION ['cart'] = 'test';

and it works

Any help will be appreciated.

What is the type of $CardId value?

Session cannot save the object or complex data.

Thanks, didn’t realize there was a limitation; it was just an object. I used (string) on $CardId and it worked without a hitch.

You’re welcome, i’m new to this forum and willing to share what I know. :slight_smile: