Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Require() vs. $_SESSION[] Differences Advantages

Status
Not open for further replies.

jsweet

Technical User
Jul 28, 2006
88
US
What are the differences and/or advantages to using Require() or $_SESSION[]? I'm new to PHP. Thanks in advance.
 
They are 2 totally different things. Not even remotely related.

SESSION variables are used to store information you may use during the stay of a user in your website. such as their login, or in the case of a shopping cart there selected items.

require() is used to bring a file with php commands, functions variables etc.. into the current one so its variables and code are available in the current script.

Entry for the Require function:

Entry for the SESSION variable entry

The are used for different things. so really cannot be compared.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Since I've been doing this recently, I assume that you are looking into data filtering to secure your site. A quick search for that usually turns up the "Dispatch Method" (which uses sessions) and the "Include/Require Method". If that's what you're actually looking for, I have two suggestions.

One: word your questions better, this leads to better answers and less snark.

Two: read this -
 
oddly enough, the coding structure that I use most often is historically called the despatch method. I use sessions, but not for the despatching. For that, I pull in the appropriate scripts using require_once.

curious how the same terminology appears to be appropriated for subtly different purposes across the years!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top