Cannot set cookies when using error_page directive, why?

pdh0710 nginx-forum at
Mon Dec 26 23:37:52 UTC 2016

error_page	400 401 402 403 404 500 502 503 504	/err.html;

location = /err.html {
	root /var/www;
	add_header Set-Cookie "error_response=${status}; path=/;";


(Please excuse my English)

Above is a part of my 'nginx.conf'. My purpose is... If error occurred,
client browser gets
'err.html' with error_response=$status cookie. The 'err.html' has JavaScript
codes that
handles the error_response cookie and display related error messages.

However, when I tried "" and other urls
make error,
the client browser got 'err.html' without error_response cookie.
But when I tried "" directly, client browser
got error_response
cookie successfully.
So, I concluded Nginx does not pass cookies when using 'error_page'

Is it a Nginx bug?
Or intentionally blocked? Why?

Posted at Nginx Forum:,271704,271704#msg-271704

More information about the nginx mailing list