Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if cookies enabled

Status
Not open for further replies.

gacaccia

Technical User
Joined
May 15, 2002
Messages
258
Location
US
Hi all,

Quick question on cookies. I know the basics of creating cookies and getting info out of cookies, but I'm not sure how to check if cookies are enabled or not. I suppose I could try to create a cookie and then confirm if cookies are enabled or not by then attempting to read the cookie, but is there a more direct way of doing it?

Thanks,

Glenn
 
document.cookie = "blabla";
if (document.cookie == "") {
alert('NO');
} else {
alert('YES');
}

will something like that do the job ? ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
found this also ( )
// Check whether cookies enabled
function frasetMain_onload()
{
document.cookie = "Enabled=true";
var cookieValid = document.cookie;
// if retrieving the VALUE we just set actually works
// then we know cookies enabled
if (cookieValid.indexOf("Enabled=true") != -1)
{
cookiesEnabled = true;
}
else
{
cookiesEnabled = false;
alert("no cookie ? no candy lol");
}
} ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
thanks for the reply,

i tried the solution, but i'm running into some pretty messed up problems. for starters, the code does not appear to work. regardless of whether or not i have cookies enabled or disabled in the browser (ie5.0 on win2000), the code reports cookies to be enabled. also, when i actually check the cookies folder on the hard drive, no cookies are being saved, regardless of my browser settings.

getting frustrated at this point on what should be a simple thing. am i missing something obvious here?

glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top