Re: use SESSION variable?



Tim Roberts wrote:
"Twayne" <nobody@xxxxxxxxxxxxxxxxxxx> wrote:
My actual question is: How do I get a POST variable into a session variable so I can use it in any other page I want to use it in?
Apparently posted variables are only available in the Form page in the file called by Action=, right? But I'd like to use it in other places.

There are several ways to do this. A $_SESSION variable is one way, and in
many cases that's the most convenient. However, if you have a bunch of
pages with <form>s that succeed one another, it's also possible to pass
this kind of information as <input type=hidden> variables without the
overhead of a session.

To expand in what Tim wrote, here is what you would do in 2.php

<input type="hidden" value="<?php print $_POST['age']; ?>" >

to get the value from 1.php. Then in 3.php you would be able to get it from the $_POST['age'] coming from 2.php.

I prefer using a session variable for situations where I need it on multiple pages because then I don't have to worry about the exact order of the pages.
.