Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > cookie test?

Reply
Thread Tools

cookie test?

 
 
George Hester
Guest
Posts: n/a
 
      01-29-2004
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
__________________________________
 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      01-29-2004
See here. http://www.aspfaq.com/show.asp?id=2058

Ray at work

"George Hester" <> wrote in message
news:...
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
__________________________________


 
Reply With Quote
 
 
 
 
George Hester
Guest
Posts: n/a
 
      01-29-2004
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##...
> See here. http://www.aspfaq.com/show.asp?id=2058
>
> Ray at work
>
> "George Hester" <> wrote in message
> news:...
> 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
> __________________________________
>
>

 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      01-29-2004
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##...
> See here. http://www.aspfaq.com/show.asp?id=2058
>
> Ray at work
>
> "George Hester" <> wrote in message
> news:...
> 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
> __________________________________
>
>

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      01-29-2004
"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.


 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      01-29-2004
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#...
> "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.
>
>

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      01-29-2004
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)
 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      01-30-2004
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." <> wrote in message news:Xns9480250A5115eejj99@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)

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      01-30-2004
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" <> wrote in message
news:...
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." <> wrote in message
news:Xns9480250A5115eejj99@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)



 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      01-30-2004
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:...
> 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" <> wrote in message
> news:...
> 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." <> wrote in message
> news:Xns9480250A5115eejj99@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)

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is different between Request.Cookie and Response.Cookie ad ASP .Net 2 01-27-2006 12:54 PM
Cookie Question (IP as domain and cookie file location) =?Utf-8?B?UGF1bA==?= ASP .Net 1 01-10-2006 08:37 PM
Any downsides to cookie assignment inside custom class using HttpContext.Current? ASP.NET 2.0 cookie fix? ASP .Net 2 08-17-2005 06:43 AM
Cookie and Session Cookie Questions. Shapper ASP .Net 1 04-27-2005 11:20 AM
Session cookie? Browser instance cookie? Ben ASP .Net 3 06-03-2004 03:41 AM



Advertisments