Solved

Session login help

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

861 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