AFAIK, there are really only two ways to accomplish this task:
Carry the hidden variables through on each page (what you're currently trying to avoid)
Implement some other method of preserving state (i.e., cookies, etc)
This is due to the fact that the web browser/server connection is stateless, so you have to do one of the above in order to preserve the state of the variables.