set cookie if not already set

Valentin V. Bartenev vbart at nginx.com
Thu Dec 13 23:35:45 UTC 2012


On Thursday 13 December 2012 22:29:07 amodpandey wrote:
> 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=/";
>         ~.+$ "";
>     }
> 
[...]

This one:

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

does the same thing, but without the resource consuming regular expression.
Moreover, it looks plain and more readable.

 wbr, Valentin V. Bartenev

--
http://nginx.com/support.html
http://nginx.org/en/donation.html



More information about the nginx mailing list