Ask a Question related to Coldfusion Security, Design and Development.

  1. #1

    Default Session Login ID

    Hello,
    I was wondering if anyone could help me.
    I have designed a site with a log in and password page.
    How would call the user name in queries on other pages?
    I am able to log in using the user name and password from my database but I
    can not get the queries to work when I call the user name, I have tried
    #session.MM_Username# and #Session.StaffID# (Staff ID being the field I have
    named the user id).
    Any help would be much appriciated.
    Thanks
    Michelle




    My code for LogIn
    <td><cfinput type="text" name="StaffID" required="yes" message="Please enter
    your Staff ID">
    <input type="hidden" name="StaffID_required" value="Please enter your Staff
    ID."></td>
    </tr>
    <tr>
    <td><h4><font face="Geneva, Arial, Helvetica,
    sans-serif">Password</font></h4></td>
    <td><cfinput type="password" name="Password" required="yes" message="Please
    enter your password.">
    <input type="hidden" name="Password_required" value="Please enter a
    password."></td>
    </tr>
    <tr align="center">
    <td colspan="2"> <input type="submit" value="Login"></td>
    </tr>
    </table>
    </cfform>

    and here is my query on another page within the site

    <cfquery name="Shifts" datasource="BookingSystemDSN">
    SELECT Job.Event, Job."Date", Location.LocationName
    FROM Job, Location, Employee,
    EmpShifts WHERE Location.LocationID = Job.LocationID
    AND EmpShifts.EmpID = Employee.EmpID
    AND EmpShifts.JobID = Job.JobID
    </cfquery>

    just need the Employee.EmployeeID to equal the StaffID input in the LogIn page


    Thanks again
    Michelle


    micb Guest

  2. Similar Questions and Discussions

    1. Login/Applicationtoken/Session Variable Problem
      I am having a problem with Logging in and Session variables. I am new to ColdFusion, but program in other languages including PHP and Java. Recently...
    2. encapsulation of session/secure login: looking for perl mod
      Hi, I am learning a little about how to use Apache::Session::MySQL by playing around with the most simple examples I can come up with. I was...
    3. ASP SQL Server Database Login - Session Variable
      Hello, I have a tough one for you guys. (Atleast I've been pulling my hair out trying to figure this one out.) Thanks for taking a look at this...
    4. session problem - login screen continually reloads after pressing the login button
      I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the...
    5. Is it possible to disable telnet login session temporary in AIX?
      Hello All, I am a new to AIX and wondering if there is a way/command to disable telnet user to the system temporary. In the real world, even...
  3. #2

    Default Re: Session Login ID

    Hi Michelle,

    I don't see where you are setting the session variable or referencing the form
    variables. (Perhaps I'm missing something.) Do you have a login action page
    that captures the form inputs and stores them in session variables?

    Something like:
    <cflock type="exclusive" scope="session" timeout="30">
    <cfset Session.StaffID = #Form.StaffID#>
    </cflock>

    Then, in the query page, you could read back out the session variable, store
    it in a local variable, then use it in your query:
    <cflock type="readonly" scope="session" timeout="30">
    <cfset myStaffID = #Session.StaffID#>
    </cflock>

    <cfquery name="Shifts" datasource="BookingSystemDSN">
    SELECT Job.Event, Job."Date", Location.LocationName
    FROM Job, Location, Employee,
    EmpShifts WHERE Location.LocationID = Job.LocationID
    AND EmpShifts.EmpID = #myStaffID#
    AND EmpShifts.JobID = Job.JobID
    </cfquery>

    Hope this helps.

    Ian

    iangoethert Guest

  4. #3

    Default Re: Session Login ID

    Sorry to throw all this at you but I am doin this as my final yr project in my
    Degree, and if somehow you could help me with this section I will be eternally
    greatful! Here is my code for the LogIn page

    <cfif IsDefined("URL.MM_logout") AND URL.MM_logout EQ "1">
    <cflock scope="Session" type="Exclusive" timeout="30" throwontimeout="no">
    <cfset Session.MM_Username="">
    <cfset Session.MM_UserAuthorization="">
    </cflock>
    <cfset MM_logoutRedirectPage="LogOut.cfm">
    <cfif MM_logoutRedirectPage EQ "">
    <cfset MM_logoutRedirectPage=CGI.SCRIPT_NAME>
    </cfif>
    <cfset
    MM_logoutQuery=ListDeleteAt(CGI.QUERY_STRING,ListC ontainsNoCase(CGI.QUERY_STRING
    ,"MM_logout=","&"),"&")>
    <cfif MM_logoutQuery NEQ "">
    <cfif Find("?",MM_logoutRedirectPage) EQ 0>
    <cfset MM_logoutRedirectPage=MM_logoutRedirectPage & "?" &
    MM_logoutQuery>
    <cfelse>
    <cfset MM_logoutRedirectPage=MM_logoutRedirectPage & "&" &
    MM_logoutQuery>
    </cfif>
    </cfif>
    <cflocation url="#MM_logoutRedirectPage#" addtoken="no">
    </cfif>
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfif IsDefined("FORM.StaffID")>
    <cfset MM_redirectLoginSuccess="BookingIn.cfm">

    <cfset MM_redirectLoginFailed="Main_FailedLogIn.cfm">
    <cfset session.empID = form.staffID />
    <cfquery name="MM_rsUser" datasource="BookingSystemDSN">
    SELECT EmpID,Password FROM Employee WHERE EmpID='#FORM.StaffID#' AND
    Password='#FORM.Password#'
    </cfquery>
    <cfif MM_rsUser.RecordCount NEQ 0>

    <cftry>
    <cflock scope="Session" timeout="30" type="Exclusive">
    <cfset Session.MM_Username=FORM.StaffID>
    <cfset Session.MM_UserAuthorization="">
    </cflock>
    <cfif IsDefined("URL.accessdenied") AND false>
    <cfset MM_redirectLoginSuccess=URL.accessdenied>
    </cfif>
    <cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
    <cfcatch type="Lock">
    <!--- code for handling timeout of cflock --->
    </cfcatch>
    </cftry>
    </cfif>
    <cflocation url="#MM_redirectLoginFailed#" addtoken="no">
    <cfelse>
    <cfset MM_LoginAction=CGI.SCRIPT_NAME>
    <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_LoginAction=MM_LoginAction & "?" & CGI.QUERY_STRING>
    </cfif>
    </cfif>


    ---------------------------------------------------------------

    And here is my code for the other page

    <cfif IsDefined("URL.MM_logout") AND URL.MM_logout EQ "1">
    <cflock scope="Session" type="Exclusive" timeout="30" throwontimeout="no">
    <cfset Session.MM_Username="">
    <cfset Session.MM_UserAuthorization="">
    </cflock>
    <cfset MM_logoutRedirectPage="LogOut.cfm">
    <cfif MM_logoutRedirectPage EQ "">
    <cfset MM_logoutRedirectPage=CGI.SCRIPT_NAME>
    </cfif>
    <cfset
    MM_logoutQuery=ListDeleteAt(CGI.QUERY_STRING,ListC ontainsNoCase(CGI.QUERY_STRING
    ,"MM_logout=","&"),"&")>
    <cfif MM_logoutQuery NEQ "">
    <cfif Find("?",MM_logoutRedirectPage) EQ 0>
    <cfset MM_logoutRedirectPage=MM_logoutRedirectPage & "?" &
    MM_logoutQuery>
    <cfelse>
    <cfset MM_logoutRedirectPage=MM_logoutRedirectPage & "&" &
    MM_logoutQuery>
    </cfif>
    </cfif>
    <cflocation url="#MM_logoutRedirectPage#" addtoken="no">
    </cfif>
    <cflock scope="Session" type="ReadOnly" timeout="30" throwontimeout="no">
    <cfset
    MM_Username=Iif(IsDefined("Session.MM_Username")," Session.MM_Username",DE(""))>
    <cfset
    MM_UserAuthorization=Iif(IsDefined("Session.MM_Use rAuthorization"),"Session.MM_U
    serAuthorization",DE(""))>
    </cflock>
    <cfif MM_Username EQ "">
    <cfset MM_referer=CGI.SCRIPT_NAME>
    <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING>
    </cfif>
    <cfset MM_failureURL="LogIn.cfm?accessdenied=" &
    URLEncodedFormat(MM_referer)>
    <cflocation url="#MM_failureURL#" addtoken="no">
    </cfif>
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfquery name="Shifts" datasource="BookingSystemDSN">
    SELECT Job.Event, Job."Date", Location.LocationName
    FROM Job, Location, Employee,
    EmpShifts WHERE Location.LocationID = Job.LocationID
    AND EmpShifts.EmpID = Employee.EmpID
    AND EmpShifts.JobID = Job.JobID
    </cfquery>


    micb Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139