Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Im trying to set a cookie just before doing a cflocation but the cookie is never set. Why is this?

cflocation cookie doing
0
Posted

Im trying to set a cookie just before doing a cflocation but the cookie is never set. Why is this?

0

cfcookie and cflocation both write header information to the client. As ColdFusion doesn’t send out any information until after a page request has completed processing, the cflocation being the last header-writing part of your template gets to write to the header, overwriting anything that cfcookie had prepared to write. As a workaround, you could set the cookie using ColdFusion and then use the JavaScript location.href to redirect the browser.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123