document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. -- Store Location: HTTP header in variable
  2. local location_header = ngx.header.location
  3.  
  4. -- Only run if Location: header is present
  5. if location_header then
  6.   -- Set the cookie lifetime to 1 day
  7.   local expires = 3600 * 24
  8.  
  9.   -- Extract sid= value into the sid_cookie variable
  10.   local sid_cookie, err = ngx.re.match(location_header, "^http(s)?:/\\/\\.+sid=(.+)$", "io")
  11.  
  12.   -- Only run if extraction was successful
  13.   if sid_cookie then
  14.     -- Construct new cookie named sessionid from sid=
  15.     ngx.header.Set_Cookie = "sessionid=" .. sid_cookie[2] .. "; path=/; domain=.tripelover.com; Expires=" .. ngx.cookie_time(ngx.time() + expires)
  16.  
  17.     -- Sanitize sid= parameter from redirection URL in the response
  18.     ngx.header.location = ngx.re.sub(location_header, "^(http.*).sid=.*$", "$1", "o")
  19.   end
  20. end
');