I am familiar with PHP but need a solution that is in Javascript instead. I cannot use PHP in this case. Can someone help me convert this from PHP to Javascript?
My goal is to determine what "a" is in the URL first. If not available, look for a cookie. If neither available then set a default value in the cookie.
mydomain.html?a=test2
//Determine Variable A
if (isset($_GET['a'])) {
$a=$_GET['a'];
setcookie("a",$a, time()+86400); /* expire in 60 days */
} elseif (empty($_COOKIE['a'])){
$a="test1";
setcookie("a",$a, time()+86400); /* expire in 60 days */
} else {
$a=$_COOKIE['a'];
}
Thank you very much!!!
Susan