Re: [PHP] Passing variables between pages
- From: japruim@xxxxxxxxxx (Jason Pruim)
- Date: Fri, 19 Sep 2008 12:22:44 -0400
On Sep 19, 2008, at 12:11 PM, tedd wrote:
At 11:15 AM -0400 9/19/08, Jason Pruim wrote:It makes perfect sense... Was just trying to avoid sessions since this application will be limited to about 10 people and restricted to the company intranet :)
But the script is still stateless regardless of the number of people or if it's limited to the company's intranet. In either event, when the user moves from one page to another page, all the variables are lost. So, you need to use sessions or cookies.
However, there is another way, but it takes a little forethought.
The technique is simply to continue the flow of a "single" script by using includes. Here's an example:
http://www.webbytedd.com/bb/tedd/index.php
The code behind this is very simple. You simply branch to other scripts by doing this:
ob_clean;
include('the-next-script.php");
exit();
This keeps ALL the variables intact because it acts like one large script. -- it's not stateless and this technique works.
However, what I don't understand is why it isn't used more often?
Unless there is something here I don't understand, I believe I could use this technique to write all the scripts I currently use without ever using a session variable.
So if I'm understanding you right... You're suggesting that in my timecard app which has index.php (user login) and timecard.php (Actual time card app) I could simply load index.php and then on submit have it do this:
ob_clean;
include("timecard.php");
exit();
Putting that in a function, or a separate file...
And then I have my variable intact and I still get to the second page without having to use sessions?
Very interesting... This is something that I will have to play with more later...
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx
.
- Follow-Ups:
- Re: [PHP] Passing variables between pages
- From: tedd
- Re: [PHP] Passing variables between pages
- References:
- Passing variables between pages
- From: Jason Pruim
- Re: [PHP] Passing variables between pages
- From: "Dan Joseph"
- Re: [PHP] Passing variables between pages
- From: Jason Pruim
- Re: [PHP] Passing variables between pages
- From: tedd
- Passing variables between pages
- Prev by Date: Re: [PHP] Passing variables between pages
- Next by Date: Re: [PHP] wrong behaviour with is_subclass_of() ??
- Previous by thread: Re: [PHP] Passing variables between pages
- Next by thread: Re: [PHP] Passing variables between pages
- Index(es):