473,231 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

cookie test?

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

<%@language="VBScript"%>
<%
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 2450
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

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

<%@language="VBScript"%>
<%
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**************@TK2MSFTNGP10.phx.gbl...
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

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

<%@language="VBScript"%>
<%
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**************@TK2MSFTNGP10.phx.gbl...
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

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

<%@language="VBScript"%>
<%
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**************@TK2MSFTNGP12.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.public.inetserver.asp.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.redirect "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.public.inetserver.asp.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.redirect "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********@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP09.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.public.inetserver.asp.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.redirect "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@pacbell*dot*net> wrote in message news:ug**************@TK2MSFTNGP09.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********@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP09.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.public.inetserver.asp.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.redirect "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
George Hester wrote on 30 jan 2004 in
microsoft.public.inetserver.asp.general:
Maintaining the session state on the current page or the next page or
any page,


The server only "knows" it cannot maintain the session if it does not get a
session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11
OK based on that I have another idea then. Thanks. But you know I have been doing it this way for a very long time. I have Windows 2000 Professional set up and I am going to go try it over there. It has SP4 in it.

--
George Hester
__________________________________
"Evertjan." <ex**************@interxnl.net> wrote in message news:Xn********************@194.109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.public.inetserver.asp.general:
Maintaining the session state on the current page or the next page or
any page,


The server only "knows" it cannot maintain the session if it does not get a
session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.


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

Jul 19 '05 #12
All that time I been using that method. But it looks as though I must have
been living in timbuktu because it's not working over here either. You know
I tested over this and over and over till it worked. Because I also detect
when scripting is off in the same set of code. Now all that happens is the
scripting test. The cookie test just seems to have died. I hate it when
that happens. Thanks for putting up with me and the explanations.

--
George Hester
_________________________________
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.public.inetserver.asp.general:
Maintaining the session state on the current page or the next page or
any page,
The server only "knows" it cannot maintain the session if it does not get

a session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #13

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

Similar topics

16
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...
3
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:...
3
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...
6
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
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...
12
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...
5
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...
1
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...
1
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...
3
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.