Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cfapplication - how to keep login information for each page

Posted on 2004-10-06
10
Medium Priority
?
342 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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