Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

login page help

I need some help with a login page.  The user can browse our catalog of events without logging in.  When they want to purchase an event, they go to the login page.  I want them to log in and then return to the page they were on for purchase.  I also need the user to be able to login and go to the home page if they are not purchasing yet.

TIA!!

R
0
Rambie
Asked:
Rambie
1 Solution
 
mrichmonCommented:
Well the way I do this is:

1) Have a directory where login is required.  All pages related to purchasing/viewing account history/etc are located in this directory.

For the rest of this question assume you named that direcotry "Secure".  And assume you store login info in session variables.

2) In the application.cfm file have the following:
<cfif FindNoCase("Secure", CGI.SCRIPT_NAME) NEQ 0><!--- Customer is in the secure directory so must log in --->
      <cfif NOT IsDefined("Session.Customer.IsLoggedIn")>
            <cfinclude template="Secure/CustomerLogin.cfm">
            <cfabort>
      </cfif>
</cfif>

3) The login form process the login and once a person's username/password is verified looks like this:

<!--- User is logged in so send them to page they came from --->
<cfif CGI.QUERY_STRING NEQ ""><!--- Preserve URL variables if they existed --->
      <cflocation addtoken="no" url="#CGI.SCRIPT_NAME#?#CGI.QUERY_STRING#">
<cfelse><!--- No URL variables so send to clean URL --->
      <cflocation addtoken="no" url="#CGI.SCRIPT_NAME#">
</cfif>

Which sends them back to the page they were trying to access when they were redirected to the login page.

Make sure that the action tag of your login page looks like:
action="#CGI.SCRIPT_NAME#<cfif CGI.QUERY_STRING NEQ "">?#CGI.QUERY_STRING#</cfif>"  

which makes the login page submit to itself and allows the autoredirection back to whatever page was being accessed.
0
 
BugBoysWorldCommented:
when they click the "check out" option have it go to the check out page. the check out page will check to see if the user is logged in. if the user is not logged in then they wil be redirected to the login page with an additional variable of page the page you want them to return to.  on the login page you have a <cfparam name="returnpage" value="index.cfm">.  when they submit the login form and after you authenicate them you check the form variable to for which page to direct them back to.  

0
 
trailblazzyr55Commented:
Well there's a few things involved with building a login page... not to do the whole thing the idea is to build session variables into your app to maintain variables and values as the user builds a cart, either session management of cookies could work. When a user is building a cart full of items, then wants to login to complete thier session, you give them the login option, takes them to the login page... but you save the referrer info of the page you came from the #CGI.HTTP_REFERRER# variable to get the last page you were on and to send them back there if the login was succesful. You build a little logic to either send them to an error page if they didn't login correctly or send them back to the page they were on after they've been logged in. Basic idea. You can use session management to track a users items before they login or you can use cookies and this will still be maintained after they login.

hope this helps... let me know if you need any more help :o)

~trail
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
trailblazzyr55Commented:
mrichmon has a good example...

you may do a little shortening on it though...

<!--- User is logged in so send them to page they came from --->
<cfif CGI.QUERY_STRING><!--- Preserve URL variables if they existed --->
     <cflocation addtoken="no" url="#CGI.HTTP_REFERRER#">
<cfelse><!--- No URL variables so send to clean URL --->
     <cflocation addtoken="no" url="#CGI.HTTP_REFERRER#">
</cfif>

Which sends them back to the page they were trying to access when they were redirected to the login page.

Make sure that the action tag of your login page looks like:
action="#CGI.HTTP_REFERRER#"

mrichmon, wouldn't the http_referrer be better an easier than using script_name&query_string ??? just curious? :o)

reagrds,
~trail
0
 
mrichmonCommented:
easier yes - but doesn't always work.

In fact CGI.HTTP_REFERRER sends you to the page that referred you to this one.  But in my example you are on the page you were trying to access (the login screen gets embedded within that page) so the CGI.HTTP_REFERRER is often blank or will be the previous page.

I recommend using the CGI.SCRIPT_NAME and CGI.QUERY_STRING combinattion so as to avoid problems when CGI.HTTP_REFERRER ends up being blank.
0
 
RambieAuthor Commented:
thanks for the help!!!  

Sorry it took me so long to get back...

R
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now