Trouble getting confirmation of authentication

Reply

Join Date: Jun 2005
Posts: 2
Reputation: thewhitezombie is an unknown quantity at this point 
Solved Threads: 0
thewhitezombie thewhitezombie is offline Offline
Newbie Poster

Trouble getting confirmation of authentication

 
0
  #1
Jun 3rd, 2005
Hey everyone this is my first post and im very stuck. I am new to web development and am currently undertaking a College course although i cannot get much help off of my lecturer.

My website is a travel agency that allows online bookings. On my home page there is a list of special offers that the user can click on to order. The offers on display are read from a DB however i need the code to verify the user is logged in once they click on the offers link. If they are logged in they will be directed to my offers.cfm page. If the user is not logged in i need an error message to appear alerting them that they are not logged in and need to be to order these offers.

I know that sounds pretty confusing, and i am sorry but this is hard to explain for a newbie lol. I have pasted the code that i have done to display the offers, hopefully this will help.

Thanks


<cfquery name="tours" datasource="webtoursmj">
SELECT tours.departdate, packages.tourname, packages.packageid, packages.tourlocation, packages.adultprice
FROM packages INNER JOIN tours
ON packages.packageid = tours.packageid;
</cfquery>

<cfoutput query="tours">
#tourname# -
#DateFormat (departdate, "d/m/yy")# -
#tourlocation# -
£#adultprice#
<a href="offers.cfm?id=#packageid#">BOOK NOW</a><br><br>
</cfoutput>
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Trouble getting confirmation of authentication

 
0
  #2
Jun 8th, 2005
Hi, I'm new to CF as well but I hope this will be helpful.
Try using Session variables. When the user logs in, create a Session variable for him/her. Then, you may add an if-else statement to enclose the <a> tag such as, <cfif IsDefined("Session.User")> <!-- your statement --> </cfif>
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 8
Reputation: rameshsambu is an unknown quantity at this point 
Solved Threads: 0
rameshsambu's Avatar
rameshsambu rameshsambu is offline Offline
Newbie Poster

Re: Trouble getting confirmation of authentication

 
0
  #3
Oct 19th, 2006
Hi

put this inside a file application.cfm in the directory having all your cfm files
  1.  
  2. <cfapplication name="appname"
  3. sessionmanagement="yes"
  4. setclientcookies="yes"
  5. clientManagement = "yes"
  6. loginStorage="session"
  7. sessiontimeout="#CreateTimeSpan(0,0,20,0)#"/>
  8.  
  9. <!--- set initially the userLogin to be false (user hasn't logged in) --->
  10. <cfif not isDefined("Session.userLogin")>
  11. <cfset Session.userLogin = false>
  12. </cfif>
this ensures that whenever there is no variable "userLogin" in session
it is defined and its value is false
application.cfm is executed when you request any page in that directory

now inside the code you would actually do the login for the user remember to put
  1. <cfset Session.userLogin = true>

then in you "offers.cfm" page do the following
  1.  
  2. <cfif Session.userLogin eq true>
  3. <!-- do things that you want to do -->
  4. <cfelse>
  5. <!-- put the error message -->
  6. </cfif>

-ramesh
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ColdFusion Forum
Thread Tools Search this Thread



Tag cloud for ColdFusion
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC