Welcome! Log In Create A New Profile


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 :)


Any feedback?

Subject Author Posted

set cookie if not already set

amodpandey December 13, 2012 01:29PM

Re: set cookie if not already set

Valentin V. Bartenev December 13, 2012 06:36PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 281
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 466 on July 09, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready