Setting a session variable followed by a cflocation
If I want to display a message to the user(not necessarily an error message), I can set the message in the session.ErrorMessage variable, and display it on the following page. This is safe since immediately after I show the user, I remove the message from the session scope.
In the header file of a site I have the following code:
<cfoutput><span class="errorMessage">#session.ErrorMessage#</span></cfoutput>
<cfset structDelete(#session#,"ErrorMessage")>
</cfif>
I started this with only error messages, but have since expanded it for anything. Such as "Your insert statement executed perfectly". Or, "There was a problem with your insert statement"... etc.
Here's the code:
<cfset structDelete(#session#,"userId")>
<cflocation url="/login.cfm" addtoken="No">
In IE, I've been having a problem with setting the session variable and immediately following it with a cflocation tag. It works fine with Firefox, but with IE, I would get to the new page, and the session.ErrorMessage variable would not exist yet. The NEXT page I would go to would recognize the variable as existing, and display it then, which is pointless and confusing to the user.
The simple answer to this is to turn on clientmanagement in the application.cfm file.
Thats it!


There are no comments for this entry.
[Add Comment]