php objects across site

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dreamer81
    Senior Member
    • May 2005
    • 474
    • 3.7.x

    php objects across site

    Hi, what is the common way of getting php objects from one php page to another php page?

    Lets say on index.php we create a new object called User

    how do I access this object on register.php

    ????
    My site
    www.coolservice.dk
  • SNN
    Senior Member
    • Jul 2006
    • 856
    • 4.0.0

    #2
    You mean include()?

    Comment

    • r007
      Member
      • Mar 2003
      • 87
      • 3.5.x

      #3
      Originally posted by dreamer81
      how do I access this object on register.php
      You could put the user object in the $_SESSION variable.

      As long as both pages use session_start();
      -r007

      Comment

      • dreamer81
        Senior Member
        • May 2005
        • 474
        • 3.7.x

        #4
        Originally posted by SNN
        You mean include()?
        no include doesn't contain objects, it contains classes and code?

        Originally posted by r007
        You could put the user object in the $_SESSION variable.

        As long as both pages use session_start();

        I thought about that... or $GLOBALS
        but I am not sure what the common way of doing this is?? I guess it's sessions then?
        My site
        www.coolservice.dk

        Comment

        • Dean C
          Senior Member
          • Mar 2002
          • 4571
          • 3.5.x

          #5
          You should stay clear of using $GLOBALS, and stick to the superglobals instead. You can serialize your object, and carry it's state across pages using sessions. Alternatively, you could store the serialized object in a database. It's up to you really. Make sure if you're carrying it as a session variable, there's no sensitive data stored in the object, as it's readable by the user
          Dean Clatworthy - Web Developer/Designer

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...