Solved

Session login help

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

12 Experts available now in Live!

Get 1:1 Help Now