nbcit
asked on
Close PHP session without saving
I have a php that will be running for a couple minutes. I need to update a variable in the session and continue processing every 20 seconds or so.
This way I can have another script update a screen on the first scripts progress every 20 seconds or so.
I need to close the session without saving, so not to undo any changes that may take place while the script is processing. Then I need to update and save the session to keep the window that the session is open to a minimal.
How do I close an open session without saving it?
This way I can have another script update a screen on the first scripts progress every 20 seconds or so.
I need to close the session without saving, so not to undo any changes that may take place while the script is processing. Then I need to update and save the session to keep the window that the session is open to a minimal.
How do I close an open session without saving it?
ASKER
In the long script every itterattion I want to update the progress in the session. I know how many loops to need to complete. Each loop takes 10 seconds or so. And if I have 100 loops I know each time I loop I will be 1% done. As the script progresses I want to update this value, so a second script can update the page on progress.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or you can of course write the data to a database and retrieve it, any method of storing data other than sessions should work I think. a text file with one integer in it will give you the lowest overhead on the server.
ASKER
I am thinking the text file will be better than:
session_write_close();
Start Loop
session_start();
Save Stuff
session_write_close();
End Loop
session_write_close();
Start Loop
session_start();
Save Stuff
session_write_close();
End Loop
ASKER
Saving a file seemed to do the trick.
Closing sessions is done with something like session_destroy() - if you dont call this it should be fine?
Matt