August 14th, 2000, 02:26 PM
I am using CGI.pm, at the top of the script I set a cookie with survey=false.
This keeps track of whether the person has completed the form.
I then validate the form, if there is an unanswered question, I send them back to the form.
If the form IS valid, I want to change the value of the cookie I set to survey=true.
It seems I can only set one or more cookies at one point in the script. How do I change the value of a cookie that has already been set??
August 14th, 2000, 03:43 PM
As far as I know..... You can only send a cookie once each time the client downloads your page, and it needs to be in the header, so... you should be able to make an if/else statement that checks to see if the form was validated, and if it was it sends survey=true, else it sends survey=false.
But it should only do one or the other.
Does that help?
If anybody sees a point that I'm wrong on please correct me.
August 15th, 2000, 05:33 AM
You should let your cookie variable expire (just create expires's date before created day that you set for survey) then create a new cookie which the same name and new value (that you want to set) :-)
SetCookie (survey,'false','December 1, 1900 24:00:00',/your_document_path,your_domain_name,null);
SetCookie (survey,'true','December 1, 2005 00:00:00',/your_document_path,your_domain_name,null);
August 15th, 2000, 05:21 PM
I tested for the cookie (if set to yes, then exit, cause they can only fill out survey once, then if false or non-existent, I went thru and validated form, then if form valid, set the cookie.
i had to remove the print statements that were in the loop validating the form. These were mainly for my own test purposes, ie- print "answer $answ is valid" etc...so it wasn't a problem.
Thanks for the responses!