I use remote debug with PhpStorm, xdebug and nginx + php-fpm. Nginx repsond with 502 error code (Bad Gateway) when I pass XDEBUG_SESSION_START=my_ide_key
in request GET
parameter. At the same time my code breakpoints in IDE work fine. When I don't pass XDEBUG_SESSION_START
parameter nginx respond with well-formatted HTML and code 200. But obvious without this parameter it is no debugging.
In nginx error log I see notifications about to big header received from upstream. I try to dump communication between php-fpm and nginx and just one different thing is one Set-Cookie
header:
Set-Cookie: XDEBUG_SESSION=666; expires=Mon, 16-Sep-2013 16:07:28 GMT; path=/
I try to find when this headers appears in response. And I found that in my smarty plugin Smarty_Internal_Template
destructors (after last code line of my start up script) if I call headers_list()
I see growing up amount of Set-Cookie headers (equal destructor calls and Set-Cookie headers amount). I am sure that there is no one explicit header('Set-Cookie: XDEBUG_SESSION=...')
call in my code. I try to upgrade and downgrade xdebug version but still have same behavior. Place code remove_header('Set-Cookie')
at Smarty_Internal_Template
solves my problem but that is ugly hack!
Any ideas about this strange situation?