nichemtktg — 2011-09-29T18:08:25-04:00 — #1
include 'temp107h.php'; continues the session
header('Location: http://localhost/temp107h.php'); breaks the session.
How can I use header() and not break the session?
nichemtktg — 2011-09-29T21:20:28-04:00 — #2
session_start(); re-activates the session even without session_write_close().
then, what's the advantage of using use session_write_close()?
parkint — 2011-09-29T21:20:51-04:00 — #3
"...header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP."
From PHP.net (the first place to look for answers).
nichemtktg — 2011-09-29T21:40:56-04:00 — #4
I found session_write_close() in the manual. I used it thinking it would store my session array, but all it needed was session_start(); in the script called in the header to get access to the session array again.
I just wanted continued access to the session array and I thought it would be proper to close the session array with session_write_close() before re-opening it with session_start().
why should session_write_close() matter when using session_start() continues to give me access to the session array?
tangoforce — 2011-10-03T09:18:43-04:00 — #5
session_write_close writes the session back to the session file and releases it so that another instance of your php script can access it. This is handy for example if you have a script that may take a while to complete (such as a download script) which no longer needs access to the session. In this scenario if you didn't use session_write_close and you tried to call another script which uses session_start() then you would just see the browsers blue bar moving slowly as it heads towards a timeout. This is because session_start() cannot gain control of the session and effectively ends up in a queue.
It's kind of like using a Critical Section in win32 languages.