Description
Same as set_error_handler/set_exception_handler
Old legacy projects uses setcookie() methods right in place.
setcookie() should be called after cookies of current request is normalized.
For example - after logout you clear cookies. After login - you put new cookies over cleared before. You have to send new cookies otherwise 502 Bad Gateway on nginx.
Yes, could be redesigned all the logic of authorization from scratch but better if you can catch setcookie call and transform it to your response class instead of internal header() call.