<div dir="ltr"><div>Hi All,</div><div><br></div><div>I'm having trouble setting a cookie conditionally based upon</div><div>an upstream variable The hope is to cache an auth token in an</div><div>encrypted session and only go to the backend auth token generator once.</div><div><br></div><div>I have something like this but it seems set-cookie happens no matter what,</div><div>so I alternate between 'my_login=1848430=' and 'my_login='.</div><div><br></div><div>    location = /auth {</div><div>        set_decode_base32 $b32 $cookie_my_login;</div><div>        set_decrypt_session $auth_tok $b32;</div><div><br></div><div>        if ($auth_tok != '') {</div><div>            return 200;</div><div>        }</div><div><br></div><div>        include        fastcgi_params;</div><div>        fastcgi_pass   unix:/tmp/fcgi_auth_tok_gen.sock;</div><div>    }</div><div><br></div><div>    location / {</div><div>        root   /var/www;</div><div>        index  index.html index.htm;</div><div><br></div><div>        auth_request /auth;</div><div>        auth_request_set $new_auth_tok $upstream_http_auth_tok;</div><div><br></div><div>        if ($new_auth_tok != false) {</div><div>            set_encrypt_session $enc_auth_tok $new_auth_tok;</div><div>            set_encode_base32 $b32 $enc_auth_tok;</div><div>            add_header Set-Cookie 'my_login=$b32';</div><div>        }</div><div>    }</div><div><br></div><div>Ideas?<br></div></div>