variables between different php files

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

Re: variables between different php files

On Tue, 19 Jul 2005 17:31:28 +0200, Josef Blösl wrote:

Quoted text here. Click to load it

One of several ways

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


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

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.


Site Timeline