Create a Unique Session Variable base on login page
Hello:
I am building a dynamic website using Dreamweaver CS5 with Coldfusion 9.
My question is how can I set a session variable to read a certain value. That is currently when my customers go to the login page they enter their username and password. I was able to create a session variable that holds the username as the value. So throughout the website their pages read Welcome "whatever their login username was". Now I want to get the session variable to read off the same table but different field that is FullName. This way the web pages will say Welcome "FullName (based off their login username)" I figure I have to set up a query parameter but after trying and failing for four hours to produce a successful result I have resorted to posting my problem here. I appreciate the help and advice.
My information:
Datasource="Access" Table="Logininfo" (Current)Field (for session variable)="Username" (Desired)Field(for session variable)="FullName"
Currently using (from server Behaviors: Session Variable) MM_Username on each page relevant to the user.
My login page code is as follows:
Head:
<cfif IsDefined("FORM.username")>
<cfset MM_redirectLoginSuccess="members_page.cfm">
<cfset MM_redirectLoginFailed="sorry.cfm">
<cfquery name="MM_rsUser" datasource="Access">
SELECT FullName, Username,Password,AccessLevels FROM Logininfo WHERE Username=<cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="50"> AND Password=<cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="50">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.username>
<cfset Session.MM_UserAuthorization=MM_rsUser.AccessLevels[1]>
</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 & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
Body:
<h1>Login</h1>
<p>Please enter your login information form the registration page in order to access your members account page.</p>
<form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" method="POST" id="login"><table width="auto" border="0" align="center">
<tr>
<td><label for="username3">
<div align="right">Username:</div>
</label></td>
<td><span id="sprytextfield1">
<input type="text" name="username" id="username2" accesskey="n" tabindex="10">
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td><label for="password">
<div align="right">Password:</div>
</label></td>
<td><span id="sprypassword1">
<input type="password" name="password" id="password" accesskey="n" tabindex="15">
<span class="passwordRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="submit" id="submit" value="Login" accesskey="n" tabindex="20">
</div></td>
</tr>
</table>
</form>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
</script>
I am sure this is something simple and will show my rookie status for asking but thanks for your help!
Also is a session variable the best route to go? I will be using this to query databases to display and allow them to change contact info, also show their invoices and request services.