Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with session dropping/loosing value

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
0
0
US
NOTE: PHP based application that uses AJAX to process and render data.

I use $_SESSION to track where a user current course of action is or last action was. The idea is to store content so that if they F5 the page I would retain the information they last submitted and keep pages content in solid state.

Content would change only if (a) user changes it and/or (b) form is submitted and new tabulated results are obtained.

I am stuck using a non *SQL environment using a legacy application so storing session to *SQL is not really an option.

Most confusing is that the $_SESSION holds values such as user credential hash keys that are set upon login in. What I am loosing or not retaining is the "additional" elements
Code:
$_SESSION['rates']['request']=$_POST;
$_SESSION['rates']['response']=$ResPonse;
The first is obviously the content of the form as last submitted and ResPonse is the content obtained after form data is processed.

if I do a var_dump just after and/or before, I can see the content as I would expect. When a new page is called and the session is referenced, content is gone! In fact, even without moving from one page to the next, a simple AJAX call to a php script that simply do var_dump($_SESSION); comes back with above session elements gone or not set.

Why or what would cause these to just vanish? No changes to server at all ... since it last worked!!!




--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Solved!

I found

Code:
$_SESSION['abc']='abc'; session_write_close();

then further down
Code:
$_SESSION['rates']['request']=$_POST;
$_SESSION['rates']['response']=$ResPonse; 
session_write_close();

It appears that session_write_close() is best used ONCE within the script not as $_SESSION is being set!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top