June 26th, 2013, 02:50 AM
Problem with session and statusCode="404"
I have a problem in my website.
I declared few situations that creates 404 page.
I need some variables to my 404 page so I declared it like this:
<cfif StructKeyExists(session,"show404") >
It is going automaticly to the 404 page,
but the first time in the page the variables in the session are not exist. if I press F5 to refresh the page so they are exist.
I tried to do CFLOCK to the session,
but it didnt help.
I will be happy for any help
June 26th, 2013, 10:17 AM
I'm not sure why you're even using session variables here, can't you just set the variables normally since you're using them right away? I assume there must be something else going on that you're not showing.
June 26th, 2013, 10:50 AM
I cant declare regular variables, because it is not the same page.
the 404 page will not recognize them
June 26th, 2013, 11:15 AM
That's what I meant about there being more going on than you're showing. What version of CF are you using? In older versions, there was an issue where trying to set a cookie (which is how the session token is usually stored) and then doing a cflocation would prevent the cookie from being set.
Depending on what's going on, you might just want to pass the variables in the URL rather than using the session scope.
June 26th, 2013, 11:17 AM
June 26th, 2013, 12:31 PM
Hmm that should work then. What does the actual redirect look like? It has to be something related to the header manipulation and/or the redirect.
I'd also confirm that the variables are in the session right after you set them, as well as confirming the CF session token (cfid, cftoken, and jsessionid if applicable) after you set the session vars, and confirm that they're the same on the next page.
June 26th, 2013, 12:51 PM
is automaticly redirect me to the 404 page that I declared in my IIS.
in the first row in the 404 page I wrote:
<cfif StructKeyExists(session,show404 )>
and it is going to the else statement....
June 26th, 2013, 01:25 PM
Yeah then I'd guess it's the header change and/or however the client or IIS handle the redirect.
You can probably confirm by trying a cflocation to the 404 page or doing a cfinclude of the 404 page, instead of using the status code. If that works, it's something the browser and/or IIS is doing that's short-circuiting things.
June 26th, 2013, 01:48 PM
I tried to do include and redirect, but they both throw exception...
June 26th, 2013, 01:58 PM