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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Response.Cookies / Request.Cookies

Status
Not open for further replies.

Rexolio

Technical User
Aug 29, 2001
230
I have a form where members fill out a poll. When visitors come to my site, a pop up window reminds them to fill in the poll. Once they submit to the poll, on the confirmation page, I'm trying to set up a cookie. The reason for the cookie is so that when visitors come to my site, the pop up window won't keep appearing for them. I think I have everything right, but its not working when I submit to the poll... the pop up window still comes up. Here's my code:

==========================================================

ON THE POLL CONFIRMATION PAGE:
'add cookie **************************************
Response.Cookies("PWGREG") = Request.form("FName")

ON THE HOME PAGE:
'has visitor completed the poll ******************
strPWGREG = Request.Cookies("PWGREG")

if strPWGREG <> &quot;&quot; then

strPopUp = &quot;&quot;

else

strPopUp = &quot; onload=&quot;&quot;NewWin=window.open('a_popups/popup.html','Poll','width=250,height=250,resizable=1,scrollbars=no');&quot;&quot;&quot;

end if

THEN IN THE BODY TAG OF THE HOME PAGE:
<body bgcolor=&quot;FFFFFF&quot;<%=strPopUp%>>

==========================================================

As I said, I fill in the form/poll, but whenever I visit my hope page the popup still appears. Suggestions???


 
You need to set the expiry date of your cookie. Without an explicit expiry date, the cookie is deleted at the end of the session. Try adding this line to your code to set the expiry date to one year from now:

Response.Cookies(&quot;PWGREG&quot;) = Request.form(&quot;FName&quot;)
Response.Cookies(&quot;PWGREG&quot;).Expires = DateAdd(&quot;d&quot;,365,Date())

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top