Solved

Session login help

Posted on 2003-10-22
2
191 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now