On Sep 22, 2008, at 10:41 AM, Nathan Rixham wrote:
tedd wrote:
At 2:47 PM +0100 9/22/08, Nathan Rixham wrote:
tedd wrote:
-Stut and Nathan:
The problem was not how to pass variables between requests, but
rather how to variables between pages -- as the subject line
indicates.
ahhhhhhhhhhhhhhhh! now I follow; and surely tedd what you say is
indeed the best way of achieving this.
cheers for taking the time
Nathan:
No problem.
But here is what I would like you to consider, the next time you
are thinking about using sessions to pass variables to the next
script, try this technique instead.
You see, a few months ago I was working with another programmer who
had a script that contained far more data than what I wanted to
break down into sessions to pass to my script. So I tried this and
to my surprise it worked flawlessly.
Then I thought "Where else could I use this?" and it seems that I
can use this everywhere.
Now, I've had three hours of sleep, so my mind may be more fuzzy
than usual, but I can't think of an example where I can't use this
technique instead of using sessions.
If you can think of one, please tell me.
Cheers,
tedd
Tedd,
I just read this whole multi-threaded thread back again (seems the
php lists are multi-threaded even if php is not :p); and here's what
I've concluded.
1: "how to pass variables between pages" that is what the subject
line indicates; however the content of the mail taken in context
indicates otherwise.
"Here's some context... I am working on a timecard system where they
are presented the main page, where they login they are *brought to a
screen where they need to* clock in/out. It all starts working
great, but when they clock in/out it loses the variable that says
they are logged in so it tries to re-authenticate them which
*doesn't work since the username/password are no longer in the
$_POST array*..."
I'm completely passing the blame for all this over to Master Prium
for in-correctly titling his posts
Okay so I could have worded it better and you typoed my name :P Pruim
notice the I and the U :)
2: Passing Variables Between Scripts
hate to say this; but I was always under the impression that what
you describe was a core/fundamental part of PHP and everybody had
been doing it since PHP3. Includes share the same request scope as
the requested script; and also has access to all variables/constants
defined in it. 99.9% of scripts I've ever seen have done this; even
just when using a config.php / database.php or similar..
3: Passing Variables Between Requests.
$_SESSION; fact is HTTP is stateless; the only way to save this info
is on the server, which can only be physical disc or physical
memory; lot's of different ways of getting there; but you're gonna
have to store it on the server somewhere and standard session's are
the simplest way until you get into the ol' multiserver sessions
thing.
Honest Tedd, I've tried this; personally I won't stick anything in
session other than the odd identifier - all other bits of data and
variables I either store statically in classes or simply do not need
to use again due to the way the app's are designed.
Jason; stick the data you need in session; a little
$_SESSION['is_authed'] = $userid; or such like will suffice to
identify until you find you need more security.
that's what I've started doing, but I have run into some small issues
with sessions.. but I'm not ready to ask a question about it yet :)
Want to play with it my self first.
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php