Writing cookies

B

Brian Burgess

Hi all,

Anyone see anything wrong with the following:
***************************************************************
<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit

Dim nAcctNbr
Dim nMsgStart
Dim nMsgEnd

If Not(Request.Cookies("AcctNbr")="") Then
nAcctNbr = CInt(Request.Cookies("AcctNbr"))
End If
If Not(Request.Cookies("MsgStart")="") Then
nMsgStart = CInt(Request.Cookies("MsgStart"))
End If
If Not(Request.Cookies("MsgEnd")="") Then
nMsgEnd = CInt(Request.Cookies("MsgEnd"))
End If

If Not (Session("USE_XML") = "True") Then
%>
<HTML>
<head>
<meta name="VI60_DTCScriptingPlatform" content="Server (ASP)">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<BODY>
<form method="post" action="page2.asp" name="Page1Frm">
From: <input type="text" width=100 name="FIRST" size="20"><BR>
Until: <input type="text" width=100 name="LAST" size="20"><BR>
Bundle id: <input type="text" width=100 name="BUNDLE_ID"
size="20"><BR>
<input type="submit" value="Submit" name="submit">
</form>
<%
Else 'if using XML
nAcctNbr = 0
nMsgStart = 0
nMsgEnd = 9
Response.Cookies("AcctNbr") = nAcctNbr
Response.Cookies("MsgStart")= nMsgStart
Response.Cookies("MsgEnd") = nMsgEnd
Response.Cookies("AcctNbr").Expires = DateAdd("d", 2, Now)
Response.Cookies("MsgStart").Expires= DateAdd("d", 2, Now)
Response.Cookies("MsgEnd").Expires = DateAdd("d", 2, Now)
%>
<HTML>
<head>
<meta name="VI60_DTCScriptingPlatform" content="Server (ASP)">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<BODY>
<FORM>
<XML ID="XMLID">
<%
Response.write "Finished."
%>
</XML>
<script language="JavaScript">
<!--
alert("Finished...");
-->
</script>
<BR>Complete<p><BR>
</FORM>
</BODY>
</HTML>
<%
End if 'USE_XML
%>
***************************************************************

This has been tested on IE60 and Pocket IE. The cookies are NOT
writing to either browser.. :-(

Thanks for any insight in advance..

-BB
 
B

Brian Burgess

Your refering to the USE_XML condition?

Yes this gets executed correctly .. I get the 'alert("Finished.")'
message in the <script> below the code for setting the cookies.
 
M

Mike Moore [MSFT]

Hi Brian,

The code that sets the cookies is in an IF statement. Perhaps that section
of the IF statement is not being executed. Please move your Response.write
"Finished" statement to the ELSE section of the IF statement to verify that
the ELSE section is being executed.

Also, as an additional test, you have a segment of code as follows:
If Not(Request.Cookies("AcctNbr")="") Then
nAcctNbr = CInt(Request.Cookies("AcctNbr"))
End If

Change this to:
If Not(Request.Cookies("AcctNbr")="") Then
nAcctNbr = CInt(Request.Cookies("AcctNbr"))
Response.write Request.Cookies("AcctNbr")
End If

Thank you, Mike
Microsoft, ASP.NET

Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-039? If not, Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-039
http://www.microsoft.com/technet/security/bulletin/ms03-039.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the Windows Update scan will help to insure you are current
with all security patches, not just MS03-039.

Microsoft also highly recommends to all customers that you visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

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


--------------------
 
B

Brian Burgess

Well I have tried both these already for verification. Just is not
included in the code posted here for simplicity sake. Yes it is
verified that the proper section executes. Actually I can even step
through in a VID debugger...
 
B

Brian Burgess

This ASP is in a file that gets Server.Execute'd in a loop. If the
Server.Execute in the calling ASP is within an HTML tag, will that
have an effect?
 
M

Mike Moore [MSFT]

Hi Brian,

Sorry for the delay. It does not matter if the server-side code is inside
an HTML tag. The server-side code can be anywhere in the page.

I'd like to return to basics for this. Please start a new blank page and
add this code. Then browse it and then refresh the page with IE and Pocket
IE. Then post the results.
<%
Response.Write Request.Cookies("abc")
Response.Cookies("abc") = "123"
Response.CacheControl="no-cache"
%>

Thank you, Mike
Microsoft, ASP.NET

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

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


--------------------
From: Brian Burgess <[email protected]>
Subject: Re: Writing cookies
Date: Thu, 11 Sep 2003 08:19:46 +0800
Message-ID: <[email protected]>
References: <[email protected]>
<[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top