help needed with cfapplication

What do i need to do inorder to display on my web page the current user who is signed in?

ive looked into it online and discovered that i need to have; sessionsenabled="yes" in my cfapplication but thats as much as i can find out.

could someone please give me an A,B,C step by step of what to do please.
LVL 1
bede123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

srikanthmadishettiCommented:
frist step

<cfapplication name="" sessionmanagement="yes"> in app.cfm

then in your login.cfm
query to check in authentication....
<cfquery name="qryLogin" datasource="#application.sDataSource#">
        get all the details of user if authentication passes
  </cfquery>

then write the followign statements to keep the values of the logged in user in to session variables
      <cflock scope="session" timeout="10">
       <cfscript>
            session.userid = qryLogin.id;
            session.username = qryLogin.name;
            session.location = qryLogin.location;
            
       </cfscript>      
      </cflock>

in pages you want you can display name  just say #session.username# and and want to diaply location #session.location#
 
 
0
bede123Author Commented:
ok, thanks for your help so far. just need a bit more from you.

this is my application.cfm so far do i need to add anything else?

<cfapplication sessionmanagement="yes"
setclientcookies="yes"
name="user_details"
sessiontimeout="#CreateTimeSpan(0,0, 20, 0)#"
sessionmanagement="yes"


this is my login page so far do i need to add anything else?


<cfif IsDefined("FORM.email")>
  <cfset MM_redirectLoginSuccess="../index.cfm">
  <cfset MM_redirectLoginFailed="failedlogin.cfm">
  <cfquery  name="MM_rsUser" datasource="ukdiscountproducts">
  SELECT email,user_password,user_level FROM registered_users WHERE email=<cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="255"> AND user_password=<cfqueryparam value="#FORM.user_password#" cfsqltype="cf_sql_clob" maxlength="255">
  </cfquery>
  <cfif MM_rsUser.RecordCount NEQ 0>
    <cftry>
    <cflock scope="Session" timeout="30" type="Exclusive">
      <cfset Session.MM_Username=FORM.email>
      <cfset Session.MM_UserAuthorization=MM_rsUser.user_level[1]>
    </cflock>
    <cfif IsDefined("URL.accessdenied") AND true>
      <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 & "?" & XMLFormat(CGI.QUERY_STRING)>
  </cfif>
</cfif>

<cfquery name="qryLogin" datasource="#application.sDataSource#">
 SELECT *
 FROM registered_users
  </cfquery>



so where about does this bit go??
<cflock scope="session" timeout="10">
       <cfscript>
            session.userid = qryLogin.id;
            session.username = qryLogin.name;
            session.location = qryLogin.location;
           
       </cfscript>      
      </cflock>


thanks
0
srikanthmadishettiCommented:
your using this already    
 <cflock scope="Session" timeout="30" type="Exclusive">
      <cfset Session.MM_Username=FORM.email>
      <cfset Session.MM_UserAuthorization=MM_rsUser.user_level[1]>
    </cflock>

in my example i used cfscript which can alo be written as

<cflock scope="session" timeout="10">

            <cfset session.userid = qryLogin.id>
            <cfset session.username = qryLogin.name>
            <cfset session.location = qryLogin.location>
           
         
      </cflock>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.