473,566 Members | 3,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cookie test?

I have always used this in ASP to test if the client is accepting cookies:

<%@language="VB Script"%>
<%
Session ("nc") = 1
If Len(Session("nc ")) = 0 Then
'Cookies Off
Else
'Cookies On
End If
%>

But I only ever tested it in Microsoft Internet Explorer 6 though not sure. Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc ")) <> 0 always whether cookies are on or off. Can anyone suggest a better cookie test that will work in most browsers? Thanks.

--
George Hester
_______________ _______________ ____
Jul 19 '05 #1
12 2479
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

"George Hester" <he********@hot mail.com> wrote in message
news:es******** ******@TK2MSFTN GP11.phx.gbl...
I have always used this in ASP to test if the client is accepting cookies:

<%@language="VB Script"%>
<%
Session ("nc") = 1
If Len(Session("nc ")) = 0 Then
'Cookies Off
Else
'Cookies On
End If
%>

But I only ever tested it in Microsoft Internet Explorer 6 though not sure.
Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc ")) <> 0
always whether cookies are on or off. Can anyone suggest a better cookie
test that will work in most browsers? Thanks.

--
George Hester
_______________ _______________ ____
Jul 19 '05 #2
Thanks on the phone now:

http://support.microsoft.com/default...b;en-us;323332

--
George Hester
_______________ _______________ ____
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message news:uc******** ******@TK2MSFTN GP10.phx.gbl...
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

"George Hester" <he********@hot mail.com> wrote in message
news:es******** ******@TK2MSFTN GP11.phx.gbl...
I have always used this in ASP to test if the client is accepting cookies:

<%@language="VB Script"%>
<%
Session ("nc") = 1
If Len(Session("nc ")) = 0 Then
'Cookies Off
Else
'Cookies On
End If
%>

But I only ever tested it in Microsoft Internet Explorer 6 though not sure.
Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc ")) <> 0
always whether cookies are on or off. Can anyone suggest a better cookie
test that will work in most browsers? Thanks.



--
George Hester
_______________ _______________ ____

Jul 19 '05 #3
Well it looks like the only way to fix this perpetual ASP session is by going to SP4 in Windows 2000. Oh man. I was told that SP4 and MDAC 2.8 are NOT stable. All I know is that the last time I installed SP4 I didn't like the result. Thankfully I am not at MDAC 2.8. Well here goes or I might chicken out and go back to that method you pointed out. I used to do it that way but I found the Session without bouncing around to ASP pages to be the cleanest method. I think I'm going to that. SP4 is just too risky at this time. You know this takes almost a complete redesign of the site again becuase I use ASP session throughout.

--
George Hester
_______________ _______________ ____
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message news:uc******** ******@TK2MSFTN GP10.phx.gbl...
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

"George Hester" <he********@hot mail.com> wrote in message
news:es******** ******@TK2MSFTN GP11.phx.gbl...
I have always used this in ASP to test if the client is accepting cookies:

<%@language="VB Script"%>
<%
Session ("nc") = 1
If Len(Session("nc ")) = 0 Then
'Cookies Off
Else
'Cookies On
End If
%>

But I only ever tested it in Microsoft Internet Explorer 6 though not sure.
Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc ")) <> 0
always whether cookies are on or off. Can anyone suggest a better cookie
test that will work in most browsers? Thanks.



--
George Hester
_______________ _______________ ____

Jul 19 '05 #4
"George Hester" wrote:
Well it looks like the only way to fix this perpetual ASP session is by
going to SP4 in Windows 2000. Oh man. I was told that SP4 and MDAC 2.8 are
NOT stable.

FWIW... I'm using W2KAS SP4, MDAC 2.8 and no issues.
Jul 19 '05 #5
Sure it's worth something. You a braver person than I.

It turns out it only took a few hours to fix this perpetual ASP session issue. I have used the suggestion once before but left most of it set up just for the hellofit. So it wasn't too bad to go through and put a Response.Cookie in all the pages. So SP4 is out till the next critical issue.

One last thing before I head out into that blue yonder. It seems that this issue has to be a security issue. If the client says, "No Cookies" then no cookies should be the result. But it is not. In Windows 2000 Server SP3 Microsoft Internet Explorer 5.5 SP2 anyway.

I had all my cookies OFF and Session("nc") = 1 was still happening. That's wrong and shouldn't be.

http://support.microsoft.com/default...b;en-us;184574

http://support.microsoft.com/default...b;en-us;223799

I actually use this to my benefit.

http://support.microsoft.com/default...b;en-us;224304 but who knows if that still works. Let's see...yup it still works. Whew...

--
George Hester
_______________ _______________ ____
"Roland Hall" <nobody@nowhere > wrote in message news:eW******** ******@TK2MSFTN GP12.phx.gbl...
"George Hester" wrote:
Well it looks like the only way to fix this perpetual ASP session is by
going to SP4 in Windows 2000. Oh man. I was told that SP4 and MDAC 2.8 are
NOT stable.

FWIW... I'm using W2KAS SP4, MDAC 2.8 and no issues.

Jul 19 '05 #6
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
I had all my cookies OFF and Session("nc") = 1 was still happening.
That's wrong and shouldn't be.


I think the session is still valid ON THE SAME PAGE.

Only if you go to the next page, the session is not kept without the
session-id cookie and a new session is started.

So: =============== =============== ==
<%
session("blah") = "blop"
response.write session("blah")
' this will always write "blop"
%>

But: =============== ===============

f1.asp:
<%
session("blah") = "blop"
response.redire ct "f2.asp"
%>

f2.asp
<%
response.write session("blah")
' this will only write "blop",
' if the session persits,
' that is if session cookies are allowed
%>

=============== =============== =====

Not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #7
Hi Evertjan:

Yes that may be what's going on here. I don't know but I do know that I have been testing cookies enabled this way for two years. Also when I mentioned to Microsoft my problem they seemed to understand what I was saying. And suggested I go to SP4 to fix the issue. I believe the reason why that hotfix is no longer available is becasue regression testing probably told them it wasn't a good idea. Just speculating here of course. I don't know it's back to normal. So I dealt with it as they say.

It seems to me if the client says No Any type of Cookies there should be No Any type of Cookies. Where is Aristotle when you need him?

--
George Hester
_______________ _______________ ____
"Evertjan." <ex************ **@interxnl.net > wrote in message news:Xn******** ***********@194 .109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
I had all my cookies OFF and Session("nc") = 1 was still happening.
That's wrong and shouldn't be.


I think the session is still valid ON THE SAME PAGE.

Only if you go to the next page, the session is not kept without the
session-id cookie and a new session is started.

So: =============== =============== ==


<%
session("blah") = "blop"
response.write session("blah")
' this will always write "blop"
%>

But: =============== ===============

f1.asp:
<%
session("blah") = "blop"
response.redire ct "f2.asp"
%>

f2.asp
<%
response.write session("blah")
' this will only write "blop",
' if the session persits,
' that is if session cookies are allowed
%>

=============== =============== =====

Not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #8
As Evertjan pointed out, there is no reason to expect that your code
would work.

Your line
Session ("nc") = 1
does not send a cookie to the client, it just assigns a value to a
session variable. This action does not depend on cookies, so testing
whether this action was successful will always return true.

Think of it this way

Client send request to server (including any valid cookies it may have
for the server)
Server processes the request and send back a response (which may
include one or more new cookies in the header)
repeat etc etc

So, the only reliable way to check if the client has (session) cookies
enabled is to set a session variable in page1.asp and read it in
page2.asp

That's just how cookies work - not a MS problem or peculiarity.

Tim

"George Hester" <he********@hot mail.com> wrote in message
news:e7******** ******@TK2MSFTN GP09.phx.gbl...
Hi Evertjan:

Yes that may be what's going on here. I don't know but I do know
that I have been testing cookies enabled this way for two years. Also
when I mentioned to Microsoft my problem they seemed to understand
what I was saying. And suggested I go to SP4 to fix the issue. I
believe the reason why that hotfix is no longer available is becasue
regression testing probably told them it wasn't a good idea. Just
speculating here of course. I don't know it's back to normal. So I
dealt with it as they say.

It seems to me if the client says No Any type of Cookies there should
be No Any type of Cookies. Where is Aristotle when you need him?

--
George Hester
_______________ _______________ ____
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ***********@194 .109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
I had all my cookies OFF and Session("nc") = 1 was still happening. That's wrong and shouldn't be.


I think the session is still valid ON THE SAME PAGE.

Only if you go to the next page, the session is not kept without the
session-id cookie and a new session is started.

So: =============== =============== ==
<%
session("blah") = "blop"
response.write session("blah")
' this will always write "blop"
%>

But: =============== ===============

f1.asp:
<%
session("blah") = "blop"
response.redire ct "f2.asp"
%>

f2.asp
<%
response.write session("blah")
' this will only write "blop",
' if the session persits,
' that is if session cookies are allowed
%>

=============== =============== =====

Not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #9
Tim - "Session ("nc") = 1 does not send a cookie to the client, it just assigns a value to a session variable"

http://support.microsoft.com/default...b;en-us;184574

"Active Server Pages (ASP) uses HTTP cookies to maintain session state"

Therefore if cookies are disabled then "session state" is NOT maintained. Aristotlean logic here: (IF session state is maintained THEN cookies are enabled). Thus (If cookies are disabled THEN session state is NOT maintained).

Therefore Session("nc") should be undefined NOT = 1. Now granted at another page Session("nc") may not still be 1 but I don't understand how that makes any difference. Maintaining the session state on the current page or the next page or any page, "Active Server Pages (ASP) uses HTTP cookies to maintain session state." Now of course if there is a bug:

http://support.microsoft.com/default...b;en-us;323332

then all bets are off.

--
George Hester
_______________ _______________ ____
"Tim Williams" <saxifrax@pacbe ll*dot*net> wrote in message news:ug******** ******@TK2MSFTN GP09.phx.gbl...
As Evertjan pointed out, there is no reason to expect that your code
would work.

Your line
Session ("nc") = 1
does not send a cookie to the client, it just assigns a value to a
session variable. This action does not depend on cookies, so testing
whether this action was successful will always return true.

Think of it this way

Client send request to server (including any valid cookies it may have
for the server)
Server processes the request and send back a response (which may
include one or more new cookies in the header)
repeat etc etc

So, the only reliable way to check if the client has (session) cookies
enabled is to set a session variable in page1.asp and read it in
page2.asp

That's just how cookies work - not a MS problem or peculiarity.

Tim



"George Hester" <he********@hot mail.com> wrote in message
news:e7******** ******@TK2MSFTN GP09.phx.gbl...
Hi Evertjan:

Yes that may be what's going on here. I don't know but I do know
that I have been testing cookies enabled this way for two years. Also
when I mentioned to Microsoft my problem they seemed to understand
what I was saying. And suggested I go to SP4 to fix the issue. I
believe the reason why that hotfix is no longer available is becasue
regression testing probably told them it wasn't a good idea. Just
speculating here of course. I don't know it's back to normal. So I
dealt with it as they say.

It seems to me if the client says No Any type of Cookies there should
be No Any type of Cookies. Where is Aristotle when you need him?

--
George Hester
_______________ _______________ ____
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ***********@194 .109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
I had all my cookies OFF and Session("nc") = 1 was still happening. That's wrong and shouldn't be.


I think the session is still valid ON THE SAME PAGE.

Only if you go to the next page, the session is not kept without the
session-id cookie and a new session is started.

So: =============== =============== ==
<%
session("blah") = "blop"
response.write session("blah")
' this will always write "blop"
%>

But: =============== ===============

f1.asp:
<%
session("blah") = "blop"
response.redire ct "f2.asp"
%>

f2.asp
<%
response.write session("blah")
' this will only write "blop",
' if the session persits,
' that is if session cookies are allowed
%>

=============== =============== =====

Not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
11294
by: Phil Powell | last post by:
Fourth attempt.. it fails now in login, I check by printing $_COOKIE and there is no value there! Guys, what on earth do I do about this???? Here is the code that sets the cookie: if ($hasLoggedIn && ($row = mysql_fetch_row($query))) { setcookie('nordicnet_registration', $row, 0, '/'); @mysql_free_result($query);
3
2862
by: Stijn Goris | last post by:
hi all, Trying to get those cookies to work but they wont... Doing this. Have a page login.php wich tests the user and pass. If they are correct a cookie is set with one variable like this: setcookie ("cookieUser", $user); then the browser is sent with header("Location: spelersPage.php"); to another page. I there try to read the...
3
1680
by: Agent M | last post by:
Hi there New to PHP. Im trying to set a cookie but for some reason it wont work. The code is inside a Submit button and happens after I have read the MySQL database and succesfully retrieved the record. For some reason the cookie is not created. Here is the code setcookie("firstname",$firstname,time() + (7 * 86400));
6
2190
by: Ajay | last post by:
hi! i am printing a simple cookie, but instead of printing um=name:blah&access:admin&exp:2312390.909 its printing um="name:blah&access:admin&exp:2312390.909" why the quotes?
4
5281
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a cookie. Here is the code I have now. In the header, I have the following: <SCRIPT language="JavaScript"> var cookieStatus; if...
12
17961
by: chrism | last post by:
Hello, I have a pop-up window that I would like to appear in front of the browser home page when a user opens IE. Problem is, I'd like it to never appear again if the user navigates back to the home page during their time using the browser. However, if the user closes the browser, then reopens, the pop-up should appear again. (you may...
5
3305
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the document.cookie variable combine all cookie key=value pairs? All of the examples I've seen discuss referencing a specific cookie. I don't see how this is...
1
2208
by: Mike | last post by:
Hello, I can't find any javascript that reads and writes cookies with keys, so that it is compatible with ASP (I want to read and write cookies from both javascript and ASP) for example in ASP: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith"
1
1985
by: ticmanis | last post by:
Hello, I'm having trouble getting MSIE 6.0 (running on XP SP2) to accept a cookie which works fine in both Firefox and wget. The web server is Boa 0.94.13 (a small embedded server) using PHP 4.3.10 for CGI. Even with the lowest security settings in MSIE there is no cookie acceptance, and no "Cookie:" HTTP header is being sent back by...
3
2581
by: WayneH | last post by:
Hi - I'm trying to use javascript to determine if a user's browser has cookies enabled or not. To test: copy this code into a file with a 'html' extension, and load it into your IE browser directly, through a local web server and through a remote web server. By turning cookies on/off in your browser, running the file, then clicking the...
0
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.