Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    sessions... Object ID #1

    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?

  • #2
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    You are improbably trying to echo an object.

    Show me some of your code.

    Generally, you access session variables like this:

    PHP Code:
    <?php

    echo $_SESSION['myvar'];

    php?>

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    USA
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).

    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?>
    Last edited by Curtis D; 06-15-2006 at 04:28 AM.
    "Some people, when confronted with a problem, think, 'I know, I'll use regular expressions.' Now they have two problems."
    --Jamie Zawinski

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    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.

  • #5
    New Coder
    Join Date
    Jun 2006
    Location
    USA
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's understandable, especially when writing larger scripts. I'm glad to hear it wasn't a serious problem.
    "Some people, when confronted with a problem, think, 'I know, I'll use regular expressions.' Now they have two problems."
    --Jamie Zawinski


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •