Anthony Tantillo
Anthony Tantillo

Reputation: 299

CFCookie dies on http meta reload

So I'm writing an experiment program. One of the steps include querying an entry to see if people are ready to move on. I'm more used to PHP, so a "" always did the trick. However, with Coldufusion the following page [posted on Pastebin at the bottom of the page] runs through once, does the meta refresh, and than the cookie dies.

So with flags, I see that the cookie exsited during the first run around, but second and so forth, the cookie dies and brigns the entire experiment to a halt.

So my question is does Coldfusion's cfcookies randomly die after a meta refresh? If so, is there a ColdFusion workaround?

The page with the problem : http://pastebin.com/1BJLahHZ

The page that pulls information from a form and stores it into a cookie : http://pastebin.com/ekP5Ea0U

*The timer on the cookie is two hours [timer = createTimeSpan(0,2,0,0)] so I am pretty sure it's not that.

Thanks ahead.

Upvotes: 1

Views: 154

Answers (2)

Dale Fraser
Dale Fraser

Reputation: 4758

Cookie won't ever get set when you use <cflocation url="http://cbees-dev/newTR3/wait.cfm"> as this occurs before the page is loaded and rendered to the client, thus the cookie is never set.

Use javascript instead.

<script type="text/javascript">
    location.href='http://cbees-dev/newTR3/wait.cfm';
</script> 

Upvotes: 2

Shawn Holmes
Shawn Holmes

Reputation: 3762

You can't create a cookie, and then immediately follow it with a cflocation; the http headers necessary to pass the information to your browser to communicate that a cookie is created are flushed away when a cflocation occurs.

Re-design your logic so that your <CFCOOKIE> sets are done on pages that have no chance of being redirected away.

Upvotes: 3

Related Questions