Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Store Location: HTTP header in variable
- local location_header = ngx.header.location
- -- Only run if Location: header is present
- if location_header then
- -- Set the cookie lifetime to 1 day
- local expires = 3600 * 24
- -- Extract sid= value into the sid_cookie variable
- local sid_cookie, err = ngx.re.match(location_header, "^http(s)?:/\/\.+sid=(.+)$", "io")
- -- Only run if extraction was successful
- if sid_cookie then
- -- Construct new cookie named sessionid from sid=
- ngx.header.Set_Cookie = "sessionid=" .. sid_cookie[2] .. "; path=/; domain=.tripelover.com; Expires=" .. ngx.cookie_time(ngx.time() + expires)
- -- Sanitize sid= parameter from redirection URL in the response
- ngx.header.location = ngx.re.sub(location_header, "^(http.*).sid=.*$", "$1", "o")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment