Solved

Session login help

Posted on 2003-10-22
2
194 Views
Last Modified: 2013-12-24
hi experts,

I seem to have a login problem using sessions:

here is my Application.cfm

<cfapplication name="marketing" clientmanagement="yes" sessionmanagement="yes"
      setdomaincookies="no" setclientcookies="no">
<!--- Login check --->
<cfif not IsDefined("SESSION.Auth.IsLoggedIn")>
<cfinclude template="index.cfm">
<cfabort>
</cfif>

here is my login page:

<cfif IsDefined ("Form.user_name")>
<cfinclude template="logincheck.cfm">
</cfif>
<cfform name="loginform" action="#CGI.SCRIPT_NAME#" method="post">
      <input type="hidden" name="user_name_Required">
      <input type="hidden" name="user_pass_Required">
  <table class="thickborder" width="400" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr>
      <td class="logintitle">Growth Chart Marketing Campaign</td>
  </tr>
  <tr>
      <td bgcolor="#D6EBFF">
<table width="400" border="0" cellspacing="0" cellpadding="4">
          <tr>
            <td width="108">Username:</td>
            <td width="276"><cfinput name="user_name" type="text" value="" maxlength="25" required="yes"
                        message="Please enter your user name"></td>
          </tr>
          <tr>
            <td>Password:</td>
            <td><cfinput name="user_pass" type="password" value="" maxlength="25" required="yes"
                        message="Please enter your password"></td>
          </tr>
          <tr>
            <td><img src="images/logo.jpg" width="103" height="30"></td>
            <td align="right"><input class="btnstyle" type="submit" value="submit" border="1px"></td>
          </tr>
        </table></td>
  </tr>
</table>
</cfform>

here is my logincheck.cfm page:

<cfquery name="GetUser" datasource="gchart">
select * from users
where user_name = '#form.user_name#'
         and user_pass = '#form.user_pass#'
</cfquery>
<!--- If the user info is good, create a struct and remember the user thru the session --->
<cfif GetUser.RecordCount EQ 1>
      
            <cfset SESSION.Auth = StructNew()>
            <cfset SESSION.Auth.IsLoggedIn = "Yes">
            <cfset SESSION.Auth.user_id = GetUser.user_id>
            <cfset SESSION.Auth.user_name = GetUser.user_name>
            <cfset SESSION.Auth.user_FName = GetUser.user_FName>
            <cfset SESSION.Auth.user_Lname = GetUser.user_Lname>
<!--- Send the user to the appropriate Start page depending on the credentials --->
      <cflocation url="start_page.cfm" addtoken="no">

<cfelseif GetUser.RecordCount EQ 0>
<script>
   alert("You didn't enter your information properly or you do not have access to this information");
   self.location="index.cfm";
</script>
</cfif>

I can login fine into the start_page.cfm, everything works fantastic until here..after that I have a couple of links on the start_page.cfm file, that takes them to different location, within the Application, that requires user to be logged in, or in other words, in the context of Application.cfm. But when the user clicks on the link, the login screen comes up again. When the user logs in, start_page comes back up. so I cannot get on to any other links on the start_page.

Please help. I know I'm missing something very simple. I'm not able to pass the session values to those linked pages I guess. I'm not sure.
0
Comment
Question by:adonis1976
2 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 400 total points
ID: 9599372
Try changing your application page to this
<cfapplication name="marketing"
      clientmanagement="yes"
      clientstorage="cookie"
      setclientcookies="yes"
      sessionmanagement="yes"
      sessiontimeout="#CreateTimeSpan( 0,0,90,0)#"
      applicationtimeout="#CreateTimeSpan(0,5,30,0)#"
>

<!--- Login check --->
<cfif not IsDefined("SESSION.Auth.IsLoggedIn")>
<cfinclude template="index.cfm">
<cfabort>
</cfif>

I tested this on my webserver and it worked just fine
0
 
LVL 11

Author Comment

by:adonis1976
ID: 9599458
Thanks a bunch. That just worked like a champ for me.
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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