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!!!
Copy an object into another object as value
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Copy an object into another object as value
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.
(#10850)