thatelvis
asked on
disabled cookes request cookie and null cookie values
Hello,
I have 2 questions on implementing what I need done. am greatful for help/ input.
Q1.
<% If Request.Cookies("countrylo ng") = "" Then %>
with this if statement above, what happens when there is no cookie there, how will it validate, Am I correct in thinking that I will also need to add a if isnull like below.
<% If isnull(Request.Cookies("co untrylong" )) = ture OR Request.Cookies("countrylo ng") = "" Then %>
I am totally confused as to wheather it would need to be validated against null or not.
-------------------------- ---------- ---------- ---
Q2. the code below.
I am running an if or, if the cookie value is nothing or the cookie is not there then run this script.
<%
If isnull(Request.Cookies("co untrylong" )) = ture OR Request.Cookies("countrylo ng") = "" Then %>
<!--#include file="my_ssis/country_chec k.asp" -->
<% ' cookie location finish
End If %>
the contents of the include my_ssis/country_check.asp is below
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl ong") = ("")
'if conditions are not met below then we get the deault value above =("Internationally ")
If not RecCountry.eof then
if NOT isNull(RecCountry.Fields.I tem("count rylong").V alue) then
if (RecCountry.Fields.Item("c ountrylong ").Value) > "" Then
Response.Cookies("countryl ong") =(RecCountry.Fields.Item(" countrylon g").Value)
Response.Cookies("countryl ong").Expi res = Date + 28
Response.Cookies("name").D omain = ""
Response.Cookies("name").P ath = "/"
Response.Cookies("name").S ecure = true
End If
End If
End If
%>
My problem here is when I test this in firefox etc, I have cookies turned off and all my cache is clear. but this code runs . what I am really confused about is, when I have this on my page, <%=cStr(Request.Cookies("c ountrylong "))%> it gets populated. how can it get populated when the persons cookies are turned off. I had beleive if some one does not have cooies turned on then they will not work.
can any one help me and explain as to what might not be working.
Regards
Kenny
I have 2 questions on implementing what I need done. am greatful for help/ input.
Q1.
<% If Request.Cookies("countrylo
with this if statement above, what happens when there is no cookie there, how will it validate, Am I correct in thinking that I will also need to add a if isnull like below.
<% If isnull(Request.Cookies("co
I am totally confused as to wheather it would need to be validated against null or not.
--------------------------
Q2. the code below.
I am running an if or, if the cookie value is nothing or the cookie is not there then run this script.
<%
If isnull(Request.Cookies("co
<!--#include file="my_ssis/country_chec
<% ' cookie location finish
End If %>
the contents of the include my_ssis/country_check.asp is below
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl
'if conditions are not met below then we get the deault value above =("Internationally ")
If not RecCountry.eof then
if NOT isNull(RecCountry.Fields.I
if (RecCountry.Fields.Item("c
Response.Cookies("countryl
Response.Cookies("countryl
Response.Cookies("name").D
Response.Cookies("name").P
Response.Cookies("name").S
End If
End If
End If
%>
My problem here is when I test this in firefox etc, I have cookies turned off and all my cache is clear. but this code runs . what I am really confused about is, when I have this on my page, <%=cStr(Request.Cookies("c
can any one help me and explain as to what might not be working.
Regards
Kenny
Q2)
Not sure about firefox but how are you disabling cookies in IE?
Are you just disabling third party cookies but running this on a trusted (or local) server for example?
Not sure about firefox but how are you disabling cookies in IE?
Are you just disabling third party cookies but running this on a trusted (or local) server for example?
ASKER
I really only used the firefox one at present as it was easier to disable enable cookies. firefox have a plugin for developers that make easy work of disableing enabling things see tutorial here
http://tips.webdesign10.com/web-developer-toolbar.htm
see firefox plugin here
http://chrispederick.com/work/webdeveloper/
regards
k
http://tips.webdesign10.com/web-developer-toolbar.htm
see firefox plugin here
http://chrispederick.com/work/webdeveloper/
regards
k
well basically if a browser does have cookies disabled properly and you really have cleared the cookie associated with the sites domain your code will not load anything from it.
I can only assume that the tool is not working as you expect, i.e. not clearing the cookie already set or properly disabling them.
I would remove the code that creates the cookie from your page.
Manually check the cookie has been deleted.
Disable cookies, close and re-open the browser and try you page again, the value should not be loaded.
I can only assume that the tool is not working as you expect, i.e. not clearing the cookie already set or properly disabling them.
I would remove the code that creates the cookie from your page.
Manually check the cookie has been deleted.
Disable cookies, close and re-open the browser and try you page again, the value should not be loaded.
ASKER
Hello,
I have done as you mentioned, I removed the cookie, and manually checked that it has been deleted etc
etc but when I return to the same page with the if statement it does show the value of the cookie.
I do not have a link to my site at present only the code sorry.
I am begining to wonder
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conwinne r.asp" -->
<%
'Start cookie location start
' if they have the cookie then no need to re qeuery the countries database
If Request.Cookies("countrylo ng") = "" Then %>
<!--#include file="my_ssis/country_chec k.asp" -->
<% ' cookie location finish
End If %>
could the above be validating against a server cookie. if so I dont remember creating one.
this is the country ssi
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl ong") = ("")
'if conditions are not met below then we get the deault value above =("Internationally ")
If not RecCountry.eof then
if NOT isNull(RecCountry.Fields.I tem("count rylong").V alue) then
if (RecCountry.Fields.Item("c ountrylong ").Value) > "" Then
Response.Cookies("countryl ong") =(RecCountry.Fields.Item(" countrylon g").Value)
Response.Cookies("countryl ong").Expi res = Date + 28
Response.Cookies("name").D omain = ""
Response.Cookies("name").P ath = "/"
Response.Cookies("name").S ecure = true
End If
End If
End If
%>
I have done as you mentioned, I removed the cookie, and manually checked that it has been deleted etc
etc but when I return to the same page with the if statement it does show the value of the cookie.
I do not have a link to my site at present only the code sorry.
I am begining to wonder
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conwinne
<%
'Start cookie location start
' if they have the cookie then no need to re qeuery the countries database
If Request.Cookies("countrylo
<!--#include file="my_ssis/country_chec
<% ' cookie location finish
End If %>
could the above be validating against a server cookie. if so I dont remember creating one.
this is the country ssi
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl
'if conditions are not met below then we get the deault value above =("Internationally ")
If not RecCountry.eof then
if NOT isNull(RecCountry.Fields.I
if (RecCountry.Fields.Item("c
Response.Cookies("countryl
Response.Cookies("countryl
Response.Cookies("name").D
Response.Cookies("name").P
Response.Cookies("name").S
End If
End If
End If
%>
change the check to this
If Request.Cookies("countrylo ng") = "" Then
response.write("cookie empty")
else
response.write("cookie exists")
end if
I just want to find out if when you say "it does show the value of the cookie" that is really the case
If Request.Cookies("countrylo
response.write("cookie empty")
else
response.write("cookie exists")
end if
I just want to find out if when you say "it does show the value of the cookie" that is really the case
ASKER
Hi Again and thank you. I tried what you mentioned but added to it
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Request.Cookies("countrylo ng") = "" Then
<!--#include file="my_ssis/ztest1.asp" -->
else
<!--#include file="my_ssis/ztest2.asp" -->
end if
%>
<%
If Request.Cookies("countrylo ng") = "" Then
response.write("cookie empty and not using ssi")
else
response.write("cookie exists and not using ssi")
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
When no cookie my out put is cookie exists and not using ssi .
When yes cookie my out put is cookie exists and not using ssi
I get no out put from the if else using the ssi.
regards
kenny
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Request.Cookies("countrylo
<!--#include file="my_ssis/ztest1.asp" -->
else
<!--#include file="my_ssis/ztest2.asp" -->
end if
%>
<%
If Request.Cookies("countrylo
response.write("cookie empty and not using ssi")
else
response.write("cookie exists and not using ssi")
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
When no cookie my out put is cookie exists and not using ssi .
When yes cookie my out put is cookie exists and not using ssi
I get no out put from the if else using the ssi.
regards
kenny
okay something very odd seems to be going on.
basck to basics - write a basic page that simply sets a cookie and writes some value to it.
disable cookies in your browser, load the page, then manually check - does the cookie get created?
basck to basics - write a basic page that simply sets a cookie and writes some value to it.
disable cookies in your browser, load the page, then manually check - does the cookie get created?
ASKER
Thanks Si,
I have created this page below. I have cookies disabled in IE, I have cleared my cache and cookies etc. then I viewed the page only to be confrounted with all the content on the page. I check my cookies but none in the cookie dir.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if ("" = "") then
myExpire = DateAdd("d", 30, Now())
cookieName = "testcookie1"
Response.Cookies(cookieNam e) = "this is the cookie value hello"
Response.Cookies(cookieNam e).Expires = myExpire
Response.Cookies(cookieNam e).Path = "/"
if ("" <> "") then
Response.Cookies(cookieNam e).Domain = ""
end if
Response.Cookies(cookieNam e).Secure = 0
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<p><%=cStr(Request.Cookies ("testcook ie1"))%></ p>
<p> </p>
<p>this is a show hide, if cookie is not empty then show<br>
<br>
<% If (cStr(Request.Cookies("tes tcookie1") )) <> ("") Then 'Start ta cokie test %>
hello welcome the cookie exists
<% End If 'End ta cokie test %></p>
</body>
</html>
I have created this page below. I have cookies disabled in IE, I have cleared my cache and cookies etc. then I viewed the page only to be confrounted with all the content on the page. I check my cookies but none in the cookie dir.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
if ("" = "") then
myExpire = DateAdd("d", 30, Now())
cookieName = "testcookie1"
Response.Cookies(cookieNam
Response.Cookies(cookieNam
Response.Cookies(cookieNam
if ("" <> "") then
Response.Cookies(cookieNam
end if
Response.Cookies(cookieNam
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<p><%=cStr(Request.Cookies
<p> </p>
<p>this is a show hide, if cookie is not empty then show<br>
<br>
<% If (cStr(Request.Cookies("tes
hello welcome the cookie exists
<% End If 'End ta cokie test %></p>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi yea,
I tried it on two computers
I viewed page 1 and I opened page 2
and got "No Cookies"
I refreshed the pages a gew times but that didnt do anything.
I then went to the code and changed the 2001 to 2009. and then got "Cookies"
I am very confused and grateful for any help
Kenny
I tried it on two computers
I viewed page 1 and I opened page 2
and got "No Cookies"
I refreshed the pages a gew times but that didnt do anything.
I then went to the code and changed the 2001 to 2009. and then got "Cookies"
I am very confused and grateful for any help
Kenny
ASKER
Si Come ere,
i managed it and reliaise what the problem was.
See when I was setting the cookie
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl ong") = ("")
there is a value in "" even though no space but it was kicking in, I cant believe it myself. any way.
this is what I ended up ding in my if else and it works a treat.
<%
If (isnull(Request.Cookies("c ountrylong "))) = false Then %>
<!--#include file="my_ssiss/country_che ck.asp" -->
<% End If %>
it is checking for the exsistance of the cookie correct, but the cooke would not bethere had it not already been created, and it was created when I was setting the thing with "", so silly me HA, any way,
thank you very much and I feel today was very successful
regards
kenny
i managed it and reliaise what the problem was.
See when I was setting the cookie
<%
' Set A Cookie To Value of countrylong
Response.Cookies("countryl
there is a value in "" even though no space but it was kicking in, I cant believe it myself. any way.
this is what I ended up ding in my if else and it works a treat.
<%
If (isnull(Request.Cookies("c
<!--#include file="my_ssiss/country_che
<% End If %>
it is checking for the exsistance of the cookie correct, but the cooke would not bethere had it not already been created, and it was created when I was setting the thing with "", so silly me HA, any way,
thank you very much and I feel today was very successful
regards
kenny
Hi Kenny,
Sorry I couldnt get back to you yesterday, but looks like you finally got there thats great well done :)
Si//
Sorry I couldnt get back to you yesterday, but looks like you finally got there thats great well done :)
Si//
VBscript - you do not need to check if null here, just check if it is empty
// If cookie is not empty
if Request.Cookies("countrylo