HW#1 Q8: Cookies

Philip Greenspun's Homepage : Philip Greenspun's Homepage Discussion Forums : 6916 : One Thread
Notify me of new responses
I'm trying to send some value or values (quotation_id's to be
supressed) from my quotation.tcl page to a quotation-remove.tcl page,
where I will write that information back into a cookie in the header
and re-direct the user back to quotations.tcl.

However I don't know if I can send simple text, or a variable that may
be a list. And if I can work with a list, how can I access the values
within it? Thanks.

-- David Sirkin, September 22, 1999


You just need to send one quotation_id to quotation-remove.tcl. The preferred way is to have a 'kill' link on quotations.tcl, next to each quotation that passes the quotation_id of the quotation you want killed to quotation-remove.tcl, like this:


Your quotations-remove.tcl should just append each quotation_id to a variable, then write out the proper headers which set the cookie to the variable containing the quotation_ids and redirect back to quotations.tcl.

-- _ _, September 22, 1999

Thanks, Rolf. Your answer is helpful but leaves me uncertain about one point. I'm appending the quotation_id to some variable in quotations-remove.tcl. That variable is then placed in the header cookie. Now when quotations.tcl reads that header, does it recognize that variable as a variable, or just as text: "list=supress_list"?

And how do I get the value of that variable to pass from quotations.tcl into quotation-remove.tcl? And again, if there's a way to pass it simply, why bother with the cookie and not just pass it right back the same way?

-- David Sirkin, September 22, 1999

The list of quotation_ids is text, not a tcl variable. However since it is in a cookie, you can set it to a variable in quotations.tcl by doing

set killed_quotes [ns_set get [ns_conn headers] Cookie]

Now you can compare the quotation_id you are pulling from the database to killed_quotes and display quotations accordingly.

You don't need to pass killed_quotes to quotations-remove.tcl. You only need to pass the quotation_id of the quotation you want killed.

-- _ _, September 22, 1999