Forum Moderators: phranque

Message Too Old, No Replies

set Environment variable as cookie

         

erosik

10:06 am on Jan 24, 2009 (gmt 0)

10+ Year Member



I believe it is possible to set a cookie using the environment variable's value, for e.g i want the set the value of HTTP_HOST as cookie value. so i used the below syntax

Header set Set-Cookie ref_test=%{HTTP_HOST}e;expires=30days;path=/;domain=www.x.net;

but when the cookie is set the value of the HTTP_HOST is not transposing it is set as %{HTTP_HOST}e itself, instead of the host name

How to achieve this?

Caterham

12:00 pm on Jan 24, 2009 (gmt 0)

10+ Year Member



Can't reproduce;

Header set Set-Cookie ref=%{HTTP_HOST}e;expires=30days;path=/;domain=localhost;

returns this response header:

Set-Cookie: ref=localhost;expires=30days;path=/;domain=localhost;

If an env could not be resolved, its value should be

(null)
instead of the plain string.

erosik

6:40 am on Jan 25, 2009 (gmt 0)

10+ Year Member



Thank you very much for the quick reply,

But is there any possibility to set the value of the cookie dynamically, i mean for e.g. if

[localhost...] is hit

i want set the somedomainname as cookie.

I have done this in apache 2.x with CO flag in the rewrite rule

But can i achieve the same with apache 1.x

Caterham

5:28 pm on Jan 25, 2009 (gmt 0)

10+ Year Member



IIRC mod_headers in 1.3/1.2 doesn't support ENVs at all.

erosik

10:11 am on Jan 29, 2009 (gmt 0)

10+ Year Member



Thanks a lot for pointing this to me.