So I'm now learning about cookies and and got my cookie code form this page on w3schools.com.
Here on StackOverflow I looked up about redirecting and I've attempted to redirect to here is the cookie has not been set. This will redirect to a page on my server to accept cookie policy and customize the admin panel theme.
<!-- Javascript BEFORE page loads Starts -->
<script type="text/javascript">
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var user=getCookie("username");
if (user != "") {
alert("Cookie Set: " + user);
} else {
//user = prompt("Please enter your name:","");
if (user != "" && user != null) {
window.location.replace("http://stackoverflow.com");
}
}
}
</script>
<!-- Javascript BEFORE page loads Starts -->
</head>
<!-- Header Ends -->
<!-- Body Starts -->
<body onload="checkCookie()">