Welcome! Log In Create A New Profile

Advanced

set cookie if not already set

December 13, 2012 01:29PM
I figured out a simple solution so thought to share it ( to get feedback or may be to help ). In an earlier discussion I got to know about map and why one should avoid to use if an try to use map.

http {

map $cookie_abt $abt {
default "abt=a;Path=/";
~.+$ "";
}

server {
listen 8081;

location / {
add_header Set-Cookie $abt;
...
}
}

}

the map returns "" ( empty ) if cookie is already else the cookie value ( abt=a;Path=/" ). The good news is add_header Set-Cookie "" does not set any cookie and we are good to go :)

HTH

Any feedback?

Regards
Amod
SubjectAuthorPosted

set cookie if not already set

amodpandeyDecember 13, 2012 01:29PM

Re: set cookie if not already set

Valentin V. BartenevDecember 13, 2012 06:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 229 on August 01, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready