Skip to main content
Inspiring
July 6, 2018
Answered

StructClear 500 Error...HELP!

  • July 6, 2018
  • 3 replies
  • 1863 views

I've been working on this for a month and I'm stumped. 

This is the code to logout...

<cfscript>

   StructClear(session);

   StructClear(application);

</cfscript>

...that's it (besides some HTML "You've logged out").

This works fine on our DEV & TEST environments, but gets a 500 Error on our PROD environment.  Nothing in the error log.  I've searched exhaustively and cannot find anything.  And we have a System Admin who is difficult..."it's the code."

Any idea?

Thanks in advance.

ColdFusion v11.

This topic has been closed for replies.
Correct answer alk47655755

Finally figured this out...just one of those weird non-logical flukes.

Basically, it was a corrupt directory.  We noticed that we would get 500 errors on even basic HTML pages.  Deleting and re-creating the directory didn't work.  So we changed the directory name from "logout" to "logout2" and voila...that worked!

Hope this might help others down the road.

Thanks for everyone's assistance with this!

3 replies

alk47655755AuthorCorrect answer
Inspiring
February 18, 2019

Finally figured this out...just one of those weird non-logical flukes.

Basically, it was a corrupt directory.  We noticed that we would get 500 errors on even basic HTML pages.  Deleting and re-creating the directory didn't work.  So we changed the directory name from "logout" to "logout2" and voila...that worked!

Hope this might help others down the road.

Thanks for everyone's assistance with this!

pete_freitag
Participating Frequently
July 6, 2018

You might also want to take a look at the logs to see what exception was thrown.

I agree with Dave - if you do a structClear(application)  it is going to cause exceptions in a production environment -- the reason for this is that the application scope is shared among all users/requests for the application. So if one request clears the application scope, and another request is concurrently executing it will have expected that the application variables are defined, but since they are not (due to the structClear) it will throw an exception.

Given this, it is likely that when you look at the logs it will say the reason for the 500 exception was application.SomeVariableName is undefined.

Inspiring
July 9, 2018

Thank you all for your inputs...I greatly appreciate it!

I did try having a couple of persons logging in simultaneously to our DEV environment and then try logging out...was able to log out with no problem.  So not sure if it is the structClear(application) that is causing my problem on PROD (albeit makes sense from your details).

Also if the structClear(application) is the culprit, then I should not be getting a 500 error when running logout.cfm?clear=session which executes only structClear(session)....see code above.  Executing the structClear(session) generates the 500 error only on PROD, but not on DEV nor TEST environments.

Will implement your suggestions, but hoping someone might have a simpler flip-the-setting on IIS or CF Admin.

Thanks all!

WolfShade
Legend
July 9, 2018

The 500 error means that something is wrong with the webserver, but the webserver cannot be specific about what the error is.

Clearing the application scope, as has already been pointed out, ruins the application scope for everyone, not just the user logging out.

As Nic suggested, place the code in question between CFTRY/CFCATCH tags to see if that will shed light on this issue.

<cftry>

    your code

    <cfcatch>

          <cfmail to="you@yourdomain.com" from="webmaster@yourdomain.com" type="html" subject="error">

              <cfdump var="#cfcatch#" />

          </cfmail>

          There is an error going on; we've been notified.  We apologise for any inconvenience.<cfabort />

    </cfcatch>

</cftry>

HTH,

^ _ ^

Inspiring
July 6, 2018

If you clear the application structure on logout, it will kill app scoped variables for everyone, not just the current user.  Probably not what you intended.

Perhaps wrap with try/catch and see if the 500 still occurs. 

-Nic

Inspiring
July 6, 2018

Thanks for your explaining the clearing of the application structure, Nic.  Unfortunately I am in one of these controlled PROD environments and it will take a minimum of 4 weeks to do a release to PROD.

I have tried isolating the StructClear as such...

<cfif IsDefined("url.clear")>

  <cfset strCleared = 'None'>

  <cfif url.clear EQ 'session'>

     <cfscript>

         StructClear(session);

     </cfscript>

     <cfset strCleared = 'Session'>

  <cfelseif url.clear EQ 'application'>

     <cfscript>

         StructClear(application);

     </cfscript>

     <cfset strCleared = 'Application'>

 

  </cfif>

  <cfoutput>#EncodeForHTML(strCleared)#</cfoutput> has been cleared.

  <cfabort>

</cfif>

...and running each of these...

  • logout.cfm?clear=session
  • logout.cfm?clear=application

...and still getting a 500 error for each.  Again, happens only on PROD.  Works fine on DEV & TEST.

I'm guessing it's either a server (IIS or CF Admin) setting that is causing this error (as the logout.cfm and application.cfm codes are the same on each environment), but unable to replicate this error on DEV or TEST.

Any other ideas?

Inspiring
July 6, 2018

I remember a number of years ago it was documented to not call structClear(session).  That may have changed since CF9 or whenever that was.  What are you trying to accomplish?  I'd imagine ending the session in Application.cfc might be more what you are looking for.  In your onRequestStart you could look for a URL param or template path, and then just call onSessionEnd().

-Nic