You should use err_headers_out() and not headers_out() when you want to send cookies in the REDIRECT response.
Java code to read cookies, part of my WebAdmin project at BMT ARGOSS.
How to set/get/delete Cookies
Good programmer comments their code so that anyone can know what is happening in code. Its easy for others to edit the code.
Here is a form that asks for Name and Email address. When the form is submitted the Email address is verified first. If you put in a Name and a correct Email address, an anchor element is displayed allowing the user to download the file, two cookies are created storing the Name and Email address. If the user goes BACK in the browser and tries...