vlevsha
vlevsha

Reputation: 265

Passing SESSION variables

Let's say I have a questionnaire consisting of three pages that a user is supposed to submit. I collect variables through SESSION. Should I pass all the variables in session from page to page repeating them or could I pass variables from page one to page three? For example, I have 'first name' and 'last name' on page 1, 'email' and 'address' on page 2, 'age' and 'occupation' on page 3. Could I pass 'first name' and 'last name' from page 1 directly to page 3? Or I will have to pass them to page 2 first and then pass them again from page 2 to page 3?

Thank you!

Upvotes: 0

Views: 210

Answers (3)

Borealid
Borealid

Reputation: 98459

I think you may be misunderstanding what a "session variable" is. On the user side, there's generally a cookie with a "session ID". On the server side, there's a file containing variables and values associated with that session ID.

There is no "passing variables from page to page" - so long as the user's session cookie is maintained, all pages within the scope of the cookie have access to all the session variables.

Upvotes: 3

Jeff Mattfield
Jeff Mattfield

Reputation:

A session value persists from page to page. Once page 1 stores it, it's accessible from any page and lasts during the entire session.

Upvotes: 2

GWW
GWW

Reputation: 44093

The session variables should be persistent no matter what pages you are on. As long as you are putting the data in the session after form 1 is submitted.

Upvotes: 2

Related Questions