| | |
Trouble getting confirmation of authentication
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 2
Reputation:
Solved Threads: 0
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>
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>
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>
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
Hi
put this inside a file application.cfm in the directory having all your cfm files
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
then in you "offers.cfm" page do the following
-ramesh
put this inside a file application.cfm in the directory having all your cfm files
ColdFusion Syntax (Toggle Plain Text)
<cfapplication name="appname" sessionmanagement="yes" setclientcookies="yes" clientManagement = "yes" loginStorage="session" sessiontimeout="#CreateTimeSpan(0,0,20,0)#"/> <!--- set initially the userLogin to be false (user hasn't logged in) ---> <cfif not isDefined("Session.userLogin")> <cfset Session.userLogin = false> </cfif>
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)
<cfset Session.userLogin = true>
then in you "offers.cfm" page do the following
ColdFusion Syntax (Toggle Plain Text)
<cfif Session.userLogin eq true> <!-- do things that you want to do --> <cfelse> <!-- put the error message --> </cfif>
-ramesh
![]() |
Similar Threads
- Hotmail Access Trouble (Web Browsers)
- Skip the Recycle Bin Confirmation Message (Windows tips 'n' tweaks)
- Forms authorization, only want a few links (ASP.NET)
- Trouble opening certain files... (Windows 95 / 98 / Me)
Other Threads in the ColdFusion Forum
- Previous Thread: Sr. ColdFusion Developer NYC
- Next Thread: Error Executing Database Query on server
Views: 3615 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ColdFusion





