Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies are easy to use in ASP?

Status
Not open for further replies.

SkiCheif

Technical User
Sep 8, 2004
30
US
I need help to find out what I am missing.

I have a page that the user picks three items (a date and two names.. all in different fields)

When they submit the form, I use the following code (on the next page) to assign values to transfer over to the remainding pages that need the cookie:

Response.Cookies("MatchDate") = Request.Form("txtMatchDate")
Response.Cookies("HomeTeam") = Request.Form("cboHomeTeam")
Response.Cookies("VisitingTeam") = Request.Form("cboVisitingTeam")

I test the cookie(s) and only the 'MatchDate' cookie will display.

SO, why can't I access them all? I have been testing this in different ways for a week and it appears to be hit and miss!?! I have never seen anything like it.

The only theory that I that I am ignorant. :) I just can't figure it out.

Signed,
Frustrated and Just About Ready to Jump (Hey, I'm already bald so I can't rip my hair out)

Thanks for your help




 
Check this, this is working fine.

Page 1(form.asp)
----------------------------------------------------

<%
Response.Cookies("MatchDate") = Request.Form("txtMatchDate")
Response.Cookies("HomeTeam") = Request.Form("cboHomeTeam")
Response.Cookies("VisitingTeam") = Request.Form("cboVisitingTeam")
%>
<hr>
<form action="" method="post">
Match date<input type="text" name="txtMatchDate"><br>
Home Team<input type="text" name="cboHomeTeam"><br>
Visiting Team<input type="text" name="cboVisitingTeam"><br>
<input type="submit">
<input type="reset" name="Reset" value="Reset">
</form>

<hr>
<a href="check.asp">click</a>



------------------------------------------------------
Page 2(check.asp)
------------------------------------------------------
<%
a=Request.Cookies("MatchDate")
b=Request.Cookies("HomeTeam")
c=Request.Cookies("VisitingTeam")

%>
<hr>
Match date:-<%=a%>
<br>
Home Team:-<%=b%>
<br>
Visiting Team:- <%=c%><br>
<hr>




This should work.

Pls try.

 
SkiCheif, try Response.Writing the Request.Form values after you submit to the page that is setting the cookies. I'm wondering if it is possible the formnames don't math up or your somehow getting empty values.

-T

barcode_1.gif
 
If you are getting empty form values, make sure the form you are sending from has the correct method applied (Get or Post).
 
I did check to see that it was POST. thanks

When I submit the form I am populating a database and the information is in the fields.
However, when I submit it on the next page it crashes because the values aren't present.

I have done cookies and never have I seen this.

Thanks for the help
Keith
 
Pls check the code for the Expires attribute of the cookie.

or

Try using a Cookies collection like:-

<%
Response.Cookies("User")("MatchDate") = Request.Form("txtMatchDate")
Response.Cookies("User")("HomeTeam") = Request.Form("cboHomeTeam")
Response.Cookies("User")("VisitingTeam") = Request.Form("cboVisitingTeam")
%>


Hoping something positive this time.



Ayan Kumar Roy
India
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top