adddeveloper
Programmer
The following code isn't working. What I want to do is to write to the page or alert the user that they don't have cookies enabled if this in fact the case from their browser settings. This is to allow the user to check a checkbox so they don't see an informational screen again when they come back to our application. Any suggestions are welcome! Thanks!
So, here's what's in my <HEAD> tag:
<script language="javascript">
document.cookie = "cookiesenabled4=yes";
function createCookie(name,value,days)
{
if (document.cookie.indexOf("cookiesenabled4=") == -1)//means the user has cookies disabled on their browser
{
document.write("Please enable cookies in order to allow this window to be avoided, if desired, in the future!");
alert("You must allow cookies!");
}
else//cookies are allowed, so set this one from the checkbox1 onclick event
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</script>
**************************************
Here's what I have for my checkbox onclick event:
**************************************
<input id="Checkbox1" type="checkbox" onclick="createCookie('ppkcookie3','testcookie',60);"/>
Don't show me again!
So, here's what's in my <HEAD> tag:
<script language="javascript">
document.cookie = "cookiesenabled4=yes";
function createCookie(name,value,days)
{
if (document.cookie.indexOf("cookiesenabled4=") == -1)//means the user has cookies disabled on their browser
{
document.write("Please enable cookies in order to allow this window to be avoided, if desired, in the future!");
alert("You must allow cookies!");
}
else//cookies are allowed, so set this one from the checkbox1 onclick event
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</script>
**************************************
Here's what I have for my checkbox onclick event:
**************************************
<input id="Checkbox1" type="checkbox" onclick="createCookie('ppkcookie3','testcookie',60);"/>
Don't show me again!