I have a situtation where I need to use the variables created during a session on another page. currently, I am doing the queries twice, which seems like such a waste!
Is is possible to retrieve them via the session store?
This is my first foray into the bowels of session handling,etc, so be gentle...;)

Recommended Answers

All 3 Replies

if a session variable was set, you can access through $_SESSION

if a session variable was set, you can access through $_SESSION

I guess I just don't understand what is being stored in a session.
For instance, don't the POST vars get stored in the session automatically?
If I create other PHP variables, those have to be stored and retrieved via my code?
Are those vars then destroyed upon the session /browser close or do i have to also write some cleanup code?

As i understand it, the session is used primarily to separate users on the site , keping track of resources being by that person specifically. Like i said , I'm just not real clear about how and when to use sessions.

session data and post data are different , and they are stored differently.
to use session data in a page, you must begin it with session_begin() function, and then you could save a variable in to the session by adding it to the $_SESSION array.

we could help and explain better if you posted the code you're having trouble with :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.