I have code in which I use sessions, and after modifying session variables, session_write_close()
is called so that the session data lock is released.
Now at another point in the same script, I need to make modifications to the session variables again. However, if I call session_start() again, the "session headers already sent" error shows up.
Is there any way to modify session variables again without getting this error?
Asked
Active
Viewed 1,122 times
3

Skeets
- 4,476
- 2
- 41
- 67

Anupam khurana
- 33
- 6
1 Answers
5
You can call session_start()
, and session_write_close
as many times as you want, it wouldn't cause that error.
This error means that you've already provided some output before attempting to write to the session. You need to make sure you don't echo out anything before attempting to write to the session.

Skeets
- 4,476
- 2
- 41
- 67
-
thanks, i finally diagnosed where output was done and corrected it. this resolved the issue. – Anupam khurana Oct 09 '20 at 07:43