Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4730

Dynamic set-cookie value on redirect

$
0
0

@fayizk1 wrote:

I want to set dynamic cookie value(from rand function) while doing re-direction. First i tried set-cookie option like following:

http-request redirect code 307 location %[capture.req.uri] set-cookie test=%[rand(20)]

but this gives me:

HTTP/1.1 307 Temporary Redirect
Cache-Control: no-cache
Content-length: 0
Location: /test
Set-Cookie: test=%[rand(20)]; path=/;

after reading haproxy source code i found a workaround, adding Set-Cookie header after location with \r\n works perfectly.

http-request redirect code 307 location %[capture.req.uri]\r\nSet-Cookie:\ test=%[rand(20)]

output:

HTTP/1.1 307 Temporary Redirect
Cache-Control: no-cache
Content-length: 0
Location: /test
Set-Cookie: test=16

I want to know whether this is a good practice?.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4730

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>