set $cookie_abc "$cookie_abc";

agentzh agentzh at gmail.com
Tue Feb 12 19:57:30 UTC 2013


Hello!

On Mon, Feb 11, 2013 at 7:21 PM, amodpandey wrote:
>
> Set the value of $cookie_abc to "a"/"b" (some logic) if the cookie value is
> not coming in the request else use the value set. I am doing this in
>

If you want to set a cookie (i.e., adding Set-Cookie response headers
on the HTTP protocol level), then assigning to the Nginx variable
$cookie_XXX will not do what you want. (This has nothing to do with
Lua and this is how the Nginx core works right now.)

To achieve that, you need to add the Set-Cookie response headers
explicitly. For example, in Lua you can do something like this:

        ngx.header['Set-Cookie'] = {'a=32; path=/', 'b=4; path=/'}

will yield the HTTP response headers

    Set-Cookie: a=32; path=/
    Set-Cookie: b=4; path=/

Best regards,
-agentzh



More information about the nginx mailing list