variables between different php files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Josef Blösl

    variables between different php files

    hi,

    how must i declare a variable in php to get access from another php file
    who is later called?
  • JDS

    #2
    Re: variables between different php files

    On Tue, 19 Jul 2005 17:31:28 +0200, Josef Blösl wrote:
    [color=blue]
    > hi,
    >
    > how must i declare a variable in php to get access from another php file
    > who is later called?[/color]


    One of several ways

    1) Pass the variable value along from page to page in the URL or via an
    http POST form

    2) use SESSIONS

    3) use COOKIES

    4) include() the file inside another file and most gloabl variables are
    maintained within the scope of the included file

    5) possibly other ways.


    Now, what are you trying to do?

    --
    JDS | jeffrey@example .invalid
    | http://www.newtnotes.com
    DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

    Comment

    • dracolytch

      #3
      Re: variables between different php files

      JDS is right...

      Usually it depends on how transient the information is, how secure it
      should be, and how complex it is.

      Things that should exist for the current browsing session (like user
      ID) should be handled by session variables.

      Things that should exist between browsing sessions can be effectively
      handled by cookie.

      Things that change within a current session (such as current product
      ID) should probably be handled by URL.

      Things that should be constant between all sessions (application
      constants) should be in an include file.

      There are a few other helpful tips:
      Session variables are the most secure. Use them when you want your end
      user to not be able to read/modify the value. The major downside is
      that they won't stick around if someone bookmarks a page.

      Cookies can be destroyed when you least expect it. Thus, I recommend
      them as a cache, or cross-session storage only.

      Complex/Large data should be transferred via "other means". You'll have
      to design a technique based on the individual situation.

      ~D

      Comment

      Working...