Fix falsely assumes session was already started #16047
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix https://wordpress.org/support/topic/an-error-occurred-session-already-started/#topic-12961322-replies
refs matomo-org/matomo-for-wordpress#304
Adding this to 3.X as needed for Matomo for WordPress.
The removed code should actually not be needed as we added a while ago
session_status()
to correctly check if a session is already active or not. SID constant is not reliable.In this case problem was this https://3v4l.org/bpUFK
Basically a session was started by some other plugin causing the SID constant to be set. The plugin also directly closed the session again so we still attempted to start the session (which is correct). But then Zend falsely assumes session is started because of the SID constant when there is actually no session.
SID is not reliable for this purpose and be better to rely on
session_status()
which we added a while back