Skip to content

Instantly share code, notes, and snippets.

@vwo-kb
Last active January 22, 2020 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vwo-kb/e53ee47b50ab22a43a241c04c8c201b4 to your computer and use it in GitHub Desktop.
Save vwo-kb/e53ee47b50ab22a43a241c04c8c201b4 to your computer and use it in GitHub Desktop.
With the following script example added, cookies don’t expire and VWO don’t need to rely on local storage at all.
<?php
if (array_key_exists('HTTP_ORIGIN', $_SERVER)) {
header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
} else {
header('Access-Control-Allow-Origin:*');
}
header('Access-Control-Allow-Credentials:true');
foreach ($_COOKIE as $key => $value) {
if (preg_match('/^(_vis_opt|_vwo)/', $key)) {
// 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 e.g. for a.abc.com eTld would be abc.com. So domain should be .abc.com. If you are not sure about what is the value in your case, you can contact the VWO support team.
setcookie($key, $value, time() + 3600 * 24 * 10 * 365, "/", ".<eTld+1>");
// setcookie($key, $value, time() + 3600 * 24 * 10 * 365, "/", ".abc.com");
}
}
echo 1; // success
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment