Last active
September 4, 2019 07:39
-
-
Save vwo-kb/b7606f703e1150f01a9b014f4fd9752e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IActionResult SyncCookies() { | |
foreach(string cookieName in Request.Cookies.Keys) { | |
string pattern = @ "^(_vis_opt_|_vwo).*"; | |
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); | |
Match match = regex.Match(cookieName); | |
if (match.Success) { | |
string cookieValue = Request.Cookies[cookieName]; | |
CookieOptions option = new CookieOptions(); | |
UInt64 expiry = 315360000000 UL; | |
// Expire any VWO cookies after 10 years. | |
// Set the cookie on root path so that it's accessible on all paths | |
// Set the domain to .<eTld+1> | |
option.Expires = DateTime.Now.AddMilliseconds(expiry); | |
option.Path = "/"; | |
option.Domain = ".<eTld+1"; | |
Response.Cookies.Append(cookieName, cookieValue, option); | |
} | |
} | |
Response.Headers.Add("Access-Control-Allow-Origin", "*"); | |
return Ok(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment