Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Session login help

Posted on 2003-10-22
2
Medium Priority
?
199 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
[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
2 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 1600 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

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 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