FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-15-2003, 01:22 PM   Postid: 93767
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
detecting if Cookies are accepted?

I'm trying to figure out some way to check on an initial login page if cookies are accepted. It's easy enough to send a cookie on one page and check if it was set on a subsequent one, but that won't work particularly well in this case.

I've looked at a few JavaScript methods that supposedly work for all browsers, but none of them seem to work on IE6. I turn off cookies and they still say cookies are enabled... I didn't even bother testing on NS after that.

One example I know of that does this successfully is PayPal. If you try going to a purchase notification direct link on their site or even the login page, and do not have cookie acceptance set at the proper level, you get a stern warning. I don't see any hints in the source code how they're accomplishing it, though. Anyone know?

Dan
dank is offline   Reply With Quote
Old 08-15-2003, 01:41 PM   Postid: 93769
Jarrod
Site Owner
 
Jarrod's Avatar

Forum Notability:
334 pts: An Honor To Be Around
[Post Feedback]
 
Join Date: Jan 2003
Location: London, England
Posts: 347
Try this url. It detects whether cookies are enabled by using javascript to set a cookie, and then on the same page reads it back. Did a quick check and it worked for me on IE6.
Jarrod is offline   Reply With Quote
Old 08-15-2003, 01:52 PM   Postid: 93770
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
That was quick, thanks.

It does seem to work when I check it in IE6, but the strange thing is it doesn't work (same problem as I reported with the other JS methods) when I check it on the local server or as a HTML editor preview. I suppose the other JS methods may have actually worked and it's just that local usage bypasses normal cookie settings?

Dan
dank is offline   Reply With Quote
Old 08-15-2003, 02:01 PM   Postid: 93771
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
Yep, just uploaded the various local test copies to the FQ server and they seem to work fine in IE. It's always the little things that trip you up...

Dan
dank is offline   Reply With Quote
Old 09-30-2003, 03:56 AM   Postid: 96985
jeng1212
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Sep 2003
Location: Philippines
Posts: 5
I tried the method presented in the url. It worked in Netscape 7.0 but not in IE 6. Even if I set IE to block all cookies, it is still able to set and get the value of a cookie.

I have also tried other methods for checking cookies but it did not work. I am just simply creating a simple HTML that will be able to detect if the browser's cookie is enabled or disabled.

Please help me...

jeng1212 is offline   Reply With Quote
Old 09-30-2003, 09:42 AM   Postid: 96988
doraevon
Site Owner
 
doraevon's Avatar

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Nov 2002
Location: Clermont, FL
Posts: 84
How about a more brute force approach (I haven't tested this, so I'm not certain it would work, but on first glance the idea seems plausible)...

Initial connection:

Send a cookie test value on a blank page with a 0-second refresh where the refresh URL contains the same script name as the original URL plus something like '?login=1'.

Refresh:

Same script uses the additional information (i.e. ?login=1) to test whether the cookie is available or not. Sends the appropriate login page based on this information.

Result:

To the end user, there might be a very slight delay while the page refreshes, but it should be negligible.

Example:

Script (we'll call it index.php) is accessed the first time. Since the '?login=1' parameter is not included, index.php sends a test cookie on a blank page with the refresh tag in the header:
Code:
<html>
  <head>
    <meta http-equiv="Refresh" content="0,URL=http://somesite.bar/index.php?login=1">
  </head>
  <body>
    <!-- Just in case refresh *doesn't* work, user won't be stranded -->
    <div align="center">
    Click <a href="http://somesite.bar/index.php?login=1">
    <b>here</b></a> to log in...
    </div>
  </body>
</html>
Page will almost immediately refresh, using the '?login=1' parameter. The index.php script, detecting the '?login=1' parameter, can now check to see if the test cookie exists and act accordingly.

Summary:

Okay, maybe it would work, maybe not. But the idea might help direct you to the solution. I'll actually test this out when I get a chance, but if it does work (and suits your requirements), enjoy!

Doraevon
doraevon is offline   Reply With Quote
Old 09-30-2003, 11:10 AM   Postid: 96994
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
If I'm not mistaken, aren't there browsers out now that can disable META refreshes? If so, that would be a concern with the above approach. Maybe a 1-2 combo that first tries the refresh, then checks further down the page if it was successful (by looking for the $login == 1 setting). If it isn't, then try the previously mentioned check.

Dan
dank is offline   Reply With Quote
Old 09-30-2003, 11:25 AM   Postid: 96995
doraevon
Site Owner
 
doraevon's Avatar

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Nov 2002
Location: Clermont, FL
Posts: 84
Quote:
Originally posted by dank:
If I'm not mistaken, aren't there browsers out now that can disable META refreshes? If so, that would be a concern with the above approach. Maybe a 1-2 combo that first tries the refresh, then checks further down the page if it was successful (by looking for the $login == 1 setting). If it isn't, then try the previously mentioned check.

Dan
Dohhh!!

Now that I think about it, <meta> refresh would be one of those things that could be used to fool someone into going to a site they didn't expect. So it wouldn't suprise me if some security settings on some browsers turned this off. Oh well, so much for that idea...

Doraevon
doraevon is offline   Reply With Quote
Old 10-01-2003, 01:46 AM   Postid: 97022
jeng1212
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Sep 2003
Location: Philippines
Posts: 5
Thanks doraevon... but I tried the same approach using JSP and JavaScript but it still didn't work.



I was able to chace upon a website using PHP and it was able to check if my IE6's cookie is enabled or disabled.

Unfortunately, I am only allowed to use JavaScript and JSP to check the cookie. Almost all of the solutions presented in the tutorials and forums did not work in IE6.
jeng1212 is offline   Reply With Quote
Old 10-02-2003, 01:19 AM   Postid: 97073
LightGuide
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Mar 2001
Location: Slightly Off-Center
Posts: 634
http://www.javascripter.net/faq/arecooki.htm
LightGuide is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 01:02 PM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.