473,322 Members | 1,379 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,322 software developers and data experts.

testing for cookies

I need to test if cookies are enabled in the browser. I disabled cookies in
my browser and rebooted my browser, yet the below code still writes a cookie
and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>
Jul 22 '05 #1
3 2468
What you'd need to do is set the cookie, navigate to a new page, then try
and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies in
my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>

Jul 22 '05 #2
Thanks. That was the problem. However, is there a way to check for cookies
enabled on the same page? I set sessions on the home page and if the user
has everything disabled in their browser, they don't get set.
thanks

"Jason Brown [MSFT]" <i-******@online.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
What you'd need to do is set the cookie, navigate to a new page, then try
and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies
in my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>


Jul 22 '05 #3
No, You have to have a new request to the server after you set the cookie in
order to determine if the browser sends it back.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"shank" <sh***@tampabay.rr.com> wrote in message
news:e3**************@TK2MSFTNGP12.phx.gbl...
Thanks. That was the problem. However, is there a way to check for cookies
enabled on the same page? I set sessions on the home page and if the user
has everything disabled in their browser, they don't get set.
thanks

"Jason Brown [MSFT]" <i-******@online.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
What you'd need to do is set the cookie, navigate to a new page, then try and read the cookie. doing it in the same script won't tell you anything
useful.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.

"shank" <sh***@tampabay.rr.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
I need to test if cookies are enabled in the browser. I disabled cookies
in my browser and rebooted my browser, yet the below code still writes a
cookie and reads it correctly. Am I approaching this correctly?
thanks
<%
Response.Cookies("smcookietest") = ("8")
Response.Cookies("smcookietest").Expires = Date + 2
%>
<%
If Request.Cookies("smcookietest") <> "8" Then
Response.Redirect("error.asp?error=19")
End If
%>
<%=Request.Cookies("smcookietest")%>



Jul 22 '05 #4

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

Similar topics

2
by: Robb Shecter | last post by:
Anybody know about a Python library for testing websites? I'm thinking of something like a scriptable browser, where you could tell it to browse to a certain URL, check for the existence of...
4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
20
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
0
by: gg.2.starfire | last post by:
WebCheck (http://www.raycosoft.com/rayco/products/webcheck) is a program for testing and analyzing static or dynamic web pages. WebCheck fetches web pages, applies detailed tests to each web page...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
0
by: Sri | last post by:
Hi I am trying to figure out how to test whether my browser cookies are enabled. I used the code from the following page...
2
by: darrel | last post by:
in ASP, this seems to work to see if a cookie exists: If Request.Cookies("site")("district") Is Nothing Then In asp.net, though, it gives me a 'System.NullReferenceException: Object reference...
1
by: shank | last post by:
I need to revisit cookie testing. On the home page and every product page I write a cookie. I do this because some users enter by direct links to product pages. <%...
3
by: Hari Sekhon | last post by:
Hi everyone, I want to create a test that will do a proper login test to a web site but I need some pointers. I need to login to the website by accessing an https url and posting to that,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.