Secure Page Redirect

Hello,
  I've been using the Dreamweaver tools to secure a page.  It allows me to redirect to "sorry" page (or whatever) to direct them to login if they try to go directly to the page without logging in.

My login page then sends them to the web's default page on authorization.

What I really want to do is have them sent back to the page they wanted in the first place.

Code below as you can see has a "URL Fail" redirect.

Thanks in advance.

<cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
  <cfset MM_Username=Iif(IsDefined("Session.MM_Username"),"Session.MM_Username",DE(""))>
  <cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"),"Session.MM_UserAuthorization",DE(""))>
</cflock>
<cfif MM_Username EQ "">
  <cfset MM_referer=CGI.SCRIPT_NAME>
  <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING>
  </cfif>
  <cfset MM_failureURL="../sorry.cfm?accessdenied=" & URLEncodedFormat(MM_referer)>
  <cflocation url="#MM_failureURL#" addtoken="no">
</cfif>
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
Larry Bristersr. DeveloperAsked:
Who is Participating?
 
pcaiooConnect With a Mentor Commented:
Try This

<cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
  <cfset MM_Username=Iif(IsDefined("Session.MM_Username"),"Session.MM_Username",DE(""))>
  <cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"),"Session.MM_UserAuthorization",DE(""))>
</cflock>

<cfif MM_Username EQ "">
  <cfinclude template="../sorry.cfm">
  <cfabort>
</cfif>
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>

so when the user resubmit they will from the same page.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.