niche Posted September 29, 2011 Share Posted September 29, 2011 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? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 29, 2011 Share Posted September 29, 2011 Use session_write_close before sending the location header. Some browsers will ignore the set-cookie header if they see a location header, so you might want to start the session on a page that isn't going to redirect. Link to comment Share on other sites More sharing options...
niche Posted September 29, 2011 Author Share Posted September 29, 2011 Thanks. The manual doesn't say how to reopen the session. How's that done? Link to comment Share on other sites More sharing options...
niche Posted September 30, 2011 Author Share Posted September 30, 2011 session_start(); re-activates the session even without session_write_close(). then, what's the advantage of using use session_write_close()? Link to comment Share on other sites More sharing options...
Ingolme Posted September 30, 2011 Share Posted September 30, 2011 session_write_close() saves any changes made to the session and closes it. PHP does this automatically when a script ends, but when a location header is sent, the browser may redirect before the script has ended. If you don't call session_write_close() before sending a location header then changes to your session data may be lost. Link to comment Share on other sites More sharing options...
niche Posted October 2, 2011 Author Share Posted October 2, 2011 I understand. Thanks for your help justsomeguy and Ingolme. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.