Anupam khurana
Anupam khurana

Reputation: 33

How to start a session again after a session_write_close()

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?

Upvotes: 3

Views: 1652

Answers (1)

Skeets
Skeets

Reputation: 4838

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.

Upvotes: 5

Related Questions