Jump to content

Storing XML values in to PHP session variables?


Kristoff1875

Recommended Posts

I've currently, after some great help from Barand, got a remote XML that I grab values from, but now I am having an issue storing them in to a PHP session and I keep getting errors?

 

My values are being called as follows:

 

$make = $xml->REQUEST->MB01->MAKE; 

<p><strong>Make:</strong> <? echo $make; ?></p>

 

Which is working fine, but i've got the following:

 

<?php
session_start();

session_register('make');

$_SESSION['make'] = $make];
?>

 

Which is giving out the following error:

 

Warning: session_start() [function.session-start]: Node no longer exists in page.php on line 2

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at page.php on line 2

 

Warning: Unknown: Node no longer exists in Unknown on line 0

 

Any ideas what's up?!

 

Thanks in advance!

 

EDIT: There are currently no header functions in the coding.

Use $_SESSION[] = xxx and not session_register().

 

session_register() is deprecated, along with register_globals (out of favour for years now). Do you have an old book?

 

session_start() needs to right at the top of the page.

Also needed to add (string) to the xml call, so for anyone who ever finds this on a search:

 

$make = (string)$xml->REQUEST->MB01->MAKE; 

 

And then:

 

session_start();

$_SESSION['make'] = $make;

 

I'm assuming that is correct as it is echoing the variable correctly on the next page using:

 

<? echo $_SESSION['make']; ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.