Page 1 of 1

Copy an object into another object as value

Posted: Thu Feb 07, 2008 12:49 pm
by kcravimss
How can one copy the session object ($_SESSION) into another object as value and not as reference? The following code snippet always does the copying as reference only:
$TEMPSESSION = $_SESSION;
So changes occur in the $_SESSION reflect in the $TEMPSESSION too; which should not happen in my case.
Please let me know how to resolve this issue!!!

Re: Copy an object into another object as value

Posted: Thu Feb 07, 2008 1:04 pm
by Christopher
First, $_SESSION is an array, not an object. Second, $_SESSION is a built-in superglobal, so you can provide the functionality you want. You will need to either only use your variable and copy values to $_SESSION, or scan $_SESSION and copy values to your variable before each use.