View Full Version : sessions... Object ID #1

06-15-2006, 02:51 AM
I'm having session trouble, sometimes when I try to echo out a session value - i get Object ID #1 instead.... anyone know why that is?

06-15-2006, 04:22 AM
You are improbably trying to echo an object.

Show me some of your code.

Generally, you access session variables like this:


echo $_SESSION['myvar'];


Curtis D
06-15-2006, 04:25 AM
It seems you have stored an object in your session variable. If you are using PHP 5, you can change how an object will behave when handled as a string (See __toString() in php.net's manual: Magic Methods (http://php.net/manual/en/language.oop5.magic.php)).

It's hard to tell exactly what the problem is without seeing your code.

@xconspirisist : your PHP delimiter tags are incorrect. The closing PHP tag is ?> not php?>

06-15-2006, 09:34 AM
ahhhh, interesting. I wasnt trying to store an object in my session BUT the name of the session variable was the same as an object I had. I changed the name of the session variable and it was fine.

Curtis D
06-15-2006, 01:23 PM
That's understandable, especially when writing larger scripts. I'm glad to hear it wasn't a serious problem. :D