943,682 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Unsolved
  • Views: 3768
  • ColdFusion RSS
Jun 3rd, 2005
0

Trouble getting confirmation of authentication

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thewhitezombie is offline Offline
2 posts
since Jun 2005
Jun 8th, 2005
0

Re: Trouble getting confirmation of authentication

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>
Reputation Points: 53
Solved Threads: 1
Posting Whiz
red_evolve is offline Offline
313 posts
since Jun 2003
Oct 19th, 2006
0

Re: Trouble getting confirmation of authentication

Hi

put this inside a file application.cfm in the directory having all your cfm files
ColdFusion Syntax (Toggle Plain Text)
  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
ColdFusion Syntax (Toggle Plain Text)
  1. <cfset Session.userLogin = true>

then in you "offers.cfm" page do the following
ColdFusion Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rameshsambu is offline Offline
8 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: Sr. ColdFusion Developer NYC
Next Thread in ColdFusion Forum Timeline: Error Executing Database Query on server





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC