Welcome! Log In Create A New Profile

Advanced

Re: set $cookie_abc "$cookie_abc";

agentzh
February 11, 2013 02:48PM
Hello!

On Mon, Feb 11, 2013 at 1:49 AM, amodpandey wrote:
> I have some lua code where I play with the value of ngx.var.cookie_abc. The
> variable must exist if some assignment is done on it.
>
> To achieve this I did
>
> set $cookie_abc "$cookie_abc";
>
> The above line clears the value of $cookie_abc, where in I assumed it to be
> defaulted if the value already exists.
>

Are you sure? Which version of ngx_lua and Nginx are you using?

I've tried the following minimal example on my side with Nginx 1.2.6 +
ngx_lua 0.7.14 and it works as expected:

location = /t {
content_by_lua '
ngx.say("cookie abc: ", ngx.var.cookie_abc)
';
}

And let's use curl to access location = /t (assuming the Nginx is
listening on the local port 8080):

$ curl -H 'Cookie: abc=32' localhost:8080/t
cookie abc: 32

$ curl localhost:8080/t
cookie abc: nil

Please note that your request must actually take a Cookie request
header, otherwise the value of $cookie_abc will surely be empty (or
nil, to be more accurate).

Best regards,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

set $cookie_abc "$cookie_abc";

amodpandey February 11, 2013 04:49AM

Re: set $cookie_abc "$cookie_abc";

Ruslan Ermilov February 11, 2013 05:14AM

Re: set $cookie_abc "$cookie_abc";

amodpandey February 11, 2013 08:41AM

Re: set $cookie_abc "$cookie_abc";

Valentin V. Bartenev February 11, 2013 11:06AM

Re: set $cookie_abc "$cookie_abc";

amodpandey February 11, 2013 01:07PM

Re: set $cookie_abc "$cookie_abc";

Valentin V. Bartenev February 11, 2013 01:18PM

Re: set $cookie_abc "$cookie_abc";

amodpandey February 11, 2013 01:21PM

Re: set $cookie_abc "$cookie_abc";

dbradfield February 11, 2013 01:54PM

Re: set $cookie_abc "$cookie_abc";

agentzh February 11, 2013 02:48PM

Re: set $cookie_abc "$cookie_abc";

amodpandey February 11, 2013 10:21PM

Re: set $cookie_abc "$cookie_abc";

agentzh February 12, 2013 02:58PM

Re: set $cookie_abc "$cookie_abc";

António P. P. Almeida February 12, 2013 04:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 214
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready