Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a URL parameter dynamically

Status
Not open for further replies.

xsw1971

Programmer
Jun 21, 2001
153
US
I have a security scheme that checks if users have logged in before letting them access our pages. To make it user-friendly, I have a session variable that holds the desired URL until the user has logged in; once logged in the user is directed to the page they wanted.

The problem comes when the initial URL has URL parameters - the parameters are not included in the redirect and therefore causes errors for the user. The code is below:


This is in a file that is
Code:
<cfinclude>
'd in every file to verify if they have logged in:
Code:
<cfif session.uid eq &quot;&quot;>
  <cflocation url=&quot;/login/login.cfm?target=#cgi.script_name#&quot; addtoken=&quot;No&quot;>
</cfif>

In the login file, a session variable is created if the user tried to access a page other than the login screen:
Code:
<cfif IsDefined(&quot;URL.target&quot;)>
  <cflock scope=&quot;Session&quot; type=&quot;Exclusive&quot; timeout=&quot;10&quot;>
    <cfset session.target=#URL.target#>
  </cflock>
</cfif>

The desired page is /myPage/page.cfm?variable=&quot;x&quot;, however the cgi.script_name is only &quot;/myPage/page.cfm&quot;. Is there a URL parameter variable name comparable to cgi.script_name that I can append to the initial cflocation url?

Thanks in advance,
Jennifer
 
cgi.query_string

so, if i understand your scheme, you'll want

Code:
 <cfset goto = &quot;/login/login.cfm&quot;
      &  &quot;?target=&quot; & cgi.script_name
      &  &quot;&&quot; & query_string >
 <cflocation url = &quot;#goto#&quot; 
     addtoken=&quot;No&quot;>

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top