Nginx overwrite existing cookies with add_header

c0nw0nk nginx-forum at forum.nginx.org
Thu Aug 25 19:24:41 UTC 2016


So i am using Nginx to set a header now my PHP app sets this header too but
it sets the cookie with a domain of ".networkflare.com"

Nginx keeps setting it as "www.networkflare.com" i need to overwrite the
cookie not create a new one.

I have tried the following :

add_header Set-Cookie "logged_in=1;Path=/;Max-Age=315360000";


That created a new cookie with a domain of "www.networkflare.com" instead of
overwriting the previous cookie with a domain of ".networkflare.com"

This is also has the same outcome as above.

add_header Set-Cookie "logged_in=1;Domain=$host;Path=/;Max-Age=315360000";



Does anyone know how you can overwrite the existing cookie without having to
specify the add_header like this.

add_header Set-Cookie
"logged_in=1;Domain=.networkflare.com;Path=/;Max-Age=315360000";
The reason i can't use this method is because on the Nginx server there are
multiple hosts, it is why i try to use $host but would need to remove the
www at the start for it to work.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269189,269189#msg-269189



More information about the nginx mailing list