?
Solved

cfapplication - how to keep login information for each page

Posted on 2004-10-06
10
Medium Priority
?
339 Views
Last Modified: 2013-12-24
I'm using cfapplication and I need every page the user accesses, I need their name and employee number.

My cfapplication.cfm looks like this:

<!--- Create the application --->
<cfapplication name="myapp" clientmanagement="Yes" sessionmanagement="Yes" sessiontimeout="#CreateTimeSpan(0,4,0,0)#" applicationtimeout="#CreateTimeSpan(0,8,0,0)#" SETCLIENTCOOKIES="Yes">

<CFPARAM NAME="session.allowin" DEFAULT="false">

<cfif session.allowin neq "true">
      <cfif ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">
      <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "mgmt_home.cfm">
      <cfelse>
      <script>
              alert("You must login to access this area!");
              self.location="login.cfm";
      </script>
      </cfif>
</cfif>

My form on the login.cfm page looks like this:

<form action="mgmt_home.cfm" method="post">
<table width="65%" cellspacing="2" cellpadding="2" align="center" bgcolor="B0C4DE">
   <tr>
      <td colspan="2" align="center" class="small">
         Please enter your AWID and password.<br>
         <img src="../images/dot_clear.gif" width="1" height="10">
      </td>
   </tr>
   <tr>
      <th align="right" class="small">Login:</th>
      <td><input type="text"
         size="15"
         maxlength="7"
         name="user_name"
         value=""
         class="smallblue"
         onFocus="this.style.border='2px solid';"
         onBlur="this.style.border='1px solid';">
      </td>
   </tr>
   <tr>
      <th align="right" class="small">Password:</th>
      <td><input type="password"
         size="15"
         maxlength="8"
         name="user_pass"
         value=""
         class="smallblue"
         onFocus="this.style.border='2px solid';"
         onBlur="this.style.border='1px solid';">                                    
      </td>
   </tr>
   <tr>
      <td colspan="2" align="right"><input type="Image" src="../images/go.gif" name="login_user" value="Log In"></td>
   </tr>
</table>
</form>

And finally...my authorized login page, mgmt_home.cfm looks like this:

<!-- BEGIN LOGIN VERIFICATION -->
<!--- Get all records from the database that match this users credentials --->
<cfquery name="qVerify" datasource="myds">
    SELECT            *
    FROM            tbl_loginmgmt
    WHERE            user_name = '#user_name#'
</cfquery>

<cfif qVerify.RecordCount>
    <!--- This user has logged in correctly, change the value of the session.allowin value --->
    <cfset session.allowin = "True">
    <!--- Now welcome user and redirect to "index.cfm" --->
<cfoutput query="qVerify">

</cfoutput>      
<cfelse>
    <!--- this user did not log in correctly, alert and redirect to the login page --->
    <script>
        alert("Your credentials could not be verified, please try again!!!");
        self.location="Javascript:history.go(-1)";
    </script>
</cfif>
<!-- END LOGIN VERIFICATION -->

Now if the user clicks on a menu item off of this page and goes to the next page, I lose the user_name information.  How do I keep the qverify query information with any page the user attempts to access?
0
Comment
Question by:Lee R Liddick Jr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 21

Accepted Solution

by:
pinaldave earned 2000 total points
ID: 12241963
Hi leerljr68,
use session management and that way you can save it...
now I have noticed that you are already using the session you can do this...

<cfset session.queryname = yoruquery>

this is what you can pass to all the pages nad you can use all the param from this session.queryname

Regards,
---Pinal
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12242032
So on every page I include the statement:

<cfset session.queryname = qVerify>

qVerify being the name of my initial query on my login verification page (mgmt_home.cfm).
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12242190
Or no...it would be this...

<cfset session.qVerify = form.user_name>

And I would place this on every page?
0
The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

 
LVL 21

Expert Comment

by:pinaldave
ID: 12242484
you do not have to do that on every page... you will have to do it once where you run that query and through out the session it will be automatically be saved and you can get it on whatever page you want to use it.
Regards,
---Pinal
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12244448
make sure cookies are enabled, if not pass the #session.urlToken# with every url, i.e. < ahref="index.cfm?#session.urlToken#">test</a>

or use #urlSessionFormat("index.cfm")#
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12245120
I will finish trying that and testing on Thursday pinaldave...thank you much!
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 12245359
no problem,
Hope that I can help you,
Regards,
---Pinal
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12258684
pinaldave...I'm not getting something here...

I have application.cfm, login.cfm (which is just the login form), and mgmt_services.cfm (which is the first page the user sees when successfully logging in).  Mgmt_services.cfm is the page that also holds the query qVerify that holds the login information and the information that I want passed to every page that user accesses.

So in your example:

<cfset session.queryname = yourquery>

What does 'queryname' represent?  What does 'yourquery' represent?  And where exactly am I placing this?
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 12258828
you can put that in your application.cfm
what youcan do is that yourqury is the qurey you will run and want to store in the session variable the information of the login.
the queryname will be any variable which you want to give it the name it can be same name as your query for username or anything...
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12259491
My cfapplication.cfm now looks like this but it still isn't working...

<!--- Create the application --->
<cfapplication name="myname" clientmanagement="Yes"
                    sessionmanagement="Yes"
                    sessiontimeout="#CreateTimeSpan(0,4,0,0)#"
                    applicationtimeout="#CreateTimeSpan(0,8,0,0)#"
                              SETCLIENTCOOKIES="Yes">

<!--- Now define that this user is logged out by default --->
<CFPARAM NAME="session.allowin" DEFAULT="false">
<!--- Now if the variable "session.allowin" does not equal true, send user to the login page --->

<cfif session.allowin neq "true">
      <cfif ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">
      <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "mgmt_home.cfm">
        <cfset session.qVerify = qVerify>
      <cfelse>
      <!--- this user is not logged in, alert user and redirect to the login.cfm page --->
      <script>
              alert("You must login to access this area!");
              self.location="login.cfm";
      </script>
      </cfif>
</cfif>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question