Pull cookie values without regular expressions

Comments

8 comments

  • thiagofigueiro

    That's digital gold, Austin! cleans-up quite a bit of VCL code for anyone dealing with cookies.

    Did you measure how much extra processing this is costing your infrastructure? Any measurable added latency at all?

    0
    Comment actions Permalink
  • jasonkuhrt

    Supplying the cookie name via a table lookup doesn't seem to work though? Example: req.http.Cookie:table.lookup(relaunch, "cookieName") * fastly_service_v1.qa: [ERR] Invalid configuration for Fastly Service (5hYeq6hHppZbxco247CSKE): Syntax error: Expected ',' got '(' at: (input Line 253 Pos 35) req.http.Cookie:table.lookup(relaunch, "cookieName"), ----------------------------------#------------------------

    0
    Comment actions Permalink
  • bryanjswift

    Can this be used to unset only specific values. For example does unset req.http.Cookie:testHash remove the testHash value from the Cookie string?

    0
    Comment actions Permalink
  • Chris Hogan

    Late to the game, but yes that works. I didn't find it doc'd anywhere, but it worked when I tried it out.

    0
    Comment actions Permalink
  • 0
    Comment actions Permalink
  • Nadav Leibovitch

    is it possible to get the value of a cookie, when the name of the cookie is a variable?

    example:

    declare local var.cookiename STRING;

    set var.cookiename = "someValue"

    req.http.Cookie:var.cookiename

     

    I know it doesn't work this way, but how can I make this work when the cookie name is a variable?

    0
    Comment actions Permalink
  • Justin

    Hi Nadav Leibovitch

    You won't be able to refer to the cookie if the name is held in a variable. It has to be an actual string.

    Do you not know the name of the cookie before runtime?

    0
    Comment actions Permalink
  • Nadav Leibovitch

    Hey,

    no I don't, the cookie name changes depending on the req.url.

    0
    Comment actions Permalink

Please sign in to leave a comment.