#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    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:

    <cfset session.show404="false">
    <cfset session.url404=url>
    <cfset session.text404=text>
    <cfif StructKeyExists(session,"show404") >
    <cfheader statusCode="404">
    </cfif>

    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

    thanks
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    I cant declare regular variables, because it is not the same page.
    the 404 page will not recognize them
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Coldfusion 9
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    this line:
    <cfheader statusCode="404">
    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 )>
    ...
    <cfelse>
    ...
    </cfif>
    and it is going to the else statement....
  14. #8
  15. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    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.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    I tried to do include and redirect, but they both throw exception...
  18. #10
  19. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968

IMN logo majestic logo threadwatch logo seochat tools logo