Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

set cookie if not already set (1 reply)

$
0
0
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?

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>