Fix write() for session_regenerate_id(TRUE)

Switching the if statements, because destroy() already removed the lock.
Merge pull request #3304 from Shakespeare2000/feature/session

#3073 Fix write() for session_regenerate_id(TRUE)