Welcome! Log In Create A New Profile

Advanced

Cannot set cookies when using error_page directive, why?

December 26, 2016 06:37PM
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 "http://test.domain.com/not_exist.html" and other urls make error,
the client browser got 'err.html' without error_response cookie.
But when I tried "http://test.domain.com/err.html" directly, client browser got error_response
cookie successfully.
So, I concluded Nginx does not pass cookies when using 'error_page' directive.

Is it a Nginx bug?
Or intentionally blocked? Why?
Subject Author Posted

Cannot set cookies when using error_page directive, why?

pdh0710 December 26, 2016 06:37PM

Re: Cannot set cookies when using error_page directive, why?

Richard Stanway December 26, 2016 07:26PM

Re: Cannot set cookies when using error_page directive, why?

pdh0710 December 27, 2016 09:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready