Page 1 of 1

Passing Variables Question & Thoughts

Posted: Sat Nov 21, 2015 8:35 am
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.

Re: Passing Variables Question & Thoughts

Posted: Sun Nov 22, 2015 8:43 am
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.

Re: Passing Variables Question & Thoughts

Posted: Sun Nov 22, 2015 9:09 am
by diseman
Perfect. Thank you Sir.