Zac123
asked on
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.
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.
frist step
<cfapplication name="" sessionmanagement="yes"> in app.cfm
then in your login.cfm
query to check in authentication....
<cfquery name="qryLogin" datasource="#application.s DataSource #">
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#
<cfapplication name="" sessionmanagement="yes"> in app.cfm
then in your login.cfm
query to check in authentication....
<cfquery name="qryLogin" datasource="#application.s
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#
ASKER
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="#CreateTim eSpan(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.cf m">
<cfset MM_redirectLoginFailed="fa iledlogin. cfm">
<cfquery name="MM_rsUser" datasource="ukdiscountprod ucts">
SELECT email,user_password,user_l evel FROM registered_users WHERE email=<cfqueryparam value="#FORM.email#" cfsqltype="cf_sql_clob" maxlength="255"> AND user_password=<cfquerypara m 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.e mail>
<cfset Session.MM_UserAuthorizati on=MM_rsUs er.user_le vel[1]>
</cflock>
<cfif IsDefined("URL.accessdenie d") AND true>
<cfset MM_redirectLoginSuccess=UR L.accessde nied>
</cfif>
<cflocation url="#MM_redirectLoginSucc ess#" addtoken="no">
<cfcatch type="Lock"><!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFail ed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_ NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAct ion & "?" & XMLFormat(CGI.QUERY_STRING )>
</cfif>
</cfif>
<cfquery name="qryLogin" datasource="#application.s DataSource #">
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
this is my application.cfm so far do i need to add anything else?
<cfapplication sessionmanagement="yes"
setclientcookies="yes"
name="user_details"
sessiontimeout="#CreateTim
sessionmanagement="yes"
>
this is my login page so far do i need to add anything else?
<cfif IsDefined("FORM.email")>
<cfset MM_redirectLoginSuccess=".
<cfset MM_redirectLoginFailed="fa
<cfquery name="MM_rsUser" datasource="ukdiscountprod
SELECT email,user_password,user_l
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.e
<cfset Session.MM_UserAuthorizati
</cflock>
<cfif IsDefined("URL.accessdenie
<cfset MM_redirectLoginSuccess=UR
</cfif>
<cflocation url="#MM_redirectLoginSucc
<cfcatch type="Lock"><!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFail
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAct
</cfif>
</cfif>
<cfquery name="qryLogin" datasource="#application.s
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://tutorial355.easycfm.com/
http://www.webmonkey.com/webmonkey/00/48/index2a.html?tw=programming
http://www.webreference.com/programming/coldfusion/2/4.html