Passing Variables Question & Thoughts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
diseman
Forum Contributor
Posts: 174
Joined: Mon Jul 26, 2010 1:30 pm
Location: Florida

Passing Variables Question & Thoughts

Post by diseman »

Hi Celauran,

Did my google'ing, but wanted a definitive answer and some thoughts.

Are $_POST, $_GET, and $_SESSION the only (PHP) ways to pass variables from one page to another?

And, as far as sessions go, is it cool to load up on sessions while running a script or is it more correct to do a query on the page and use it?

My script requires a 2nd person's name, who is assigned to user, on page 1.php of 10 pages. I don't need it for pages 2-9. When I get to page 10.php, I need that person's name again. Should I query it again from db or should I just session it the entire session?

Just want to know the proper, or at least more correct, way to do it.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Passing Variables Question & Thoughts

Post by Celauran »

I think either is fine. If the name required is variable, then you may as well query for it once and store it in session data since you'd need some value to query against later on in your application. If it's not, if it's always the same, then you can just fetch it on the step where you're actually using it.
User avatar
diseman
Forum Contributor
Posts: 174
Joined: Mon Jul 26, 2010 1:30 pm
Location: Florida

Re: Passing Variables Question & Thoughts

Post by diseman »

Perfect. Thank you Sir.
Post Reply