Hi Khaled.

The way I've always done it is if the user needs to login in order to see a
page I pass the page to the login script that sets a session variable.  Upon
successful login, I then check for that session variable and bounce them
back to the page that referred them.

<cfif not isdefined("session.loggedin")>
  <cflocation url="{path to login}?referrer=#CGI.script_name#"
addtoken="no">
</cfif>

On the login page, see if "referrer" is being passed in:

<cfif isdefined("URL.referrer")>
  <cfset session.loginReferrer = URL.referrer>
</cfif>

After the user has authenticated, bounce them back to where they came from:

<cfif isDefined("session.loginReferrer")>
  <cflocation url="{your site url}#session.loginReferrer#" addtoken="no">
</cfif>

The reason I've used a session var is in case they fail the authentication
the variable persists.  You can pass the referrer as a hidden form variable
if you want instead, whatever your preference is.

Mike




-----Original Message-----
From: Khaled Elraie [mailto:[email protected]] 
Sent: Tuesday, July 19, 2011 12:05 AM
To: cf-newbie
Subject: Coming back to original page after signing in


Hi
I have been away from CF for a few years and I am re-learning my old skills.
I'm actually kinda of embarrassed to have to post on the newbie list again
:)

Say you're trying to access an area of a website that requires me to be
logged in- a shopping cart for example. So it automatically sends you to the
login page, and after login it sends you back to the shopping cart. What's
the best way to do this with CF?

I remember in the early days of Fusebox there was a custom tag by Steve
Nelson (returnfuseaction). Is that still a good way to achieve the above
goal? And if so, can someone remind me how to use it?
Thanks
Khaled 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5372
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to