Bypass login screen

I have an APPLICATION.CFM, EMLLOGIN.CFM, EMLLOGIN1.CFM and EMLLOGOUT.CFM

The EMLLOGOUT.CFM is evoked from any .cfm when the logout button is pressed.

Whenever I click on the logout button, I am presented with the login.cfm screen.

However, when I log in again (the second time),  I get the message "Element USERID is undefined in SESSION."

We are currently on CF9.

Any help would be enormously appreciated.




APPLICATION.CFM
===============
<cfcomponent>
	<cfscript>
		 this.name = "Adminpanel";
		 this.applicationTimeout = createTimeSpan(0,0,10,0);
		 this.clientmanagement= "yes";
		 this.loginstorage = "session";
		 this.sessionmanagement = "yes";
		 this.sessiontimeout = createTimeSpan(0,0,10,0);
		 this.setClientCookies = "yes";
		 this.scriptProtect = "all";

		 this.datasource = "abcdataremote";
	 </cfscript>



	<cffunction  name="onRequestStart">
	  <cfargument name="requestname" required=true/>



		<!--- SESSION LOGOUT --->
		 <cfif isDefined("session.logout")>


				<cfscript>
					StructClear(session);
				</cfscript>

				<cflogout>

		</cfif>

		<cfinclude template="emlLogin1.cfm">

	</cffunction>

</cfcomponent>

Open in new window



EMLLOGIN.CFM
=============
<cfoutput>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- saved from url=(0093)http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/finished.html -->
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Contact Info Verification</title>
    <link rel="stylesheet" type="text/css" href="CSSOneColumns.css" media="screen" />
</head>
<body>


    <cfform method="post" action="#cgi.SCRIPT_NAME#" name="adminlogin" id="adminlogin">
		<cfinclude template="emlIncludeHeaderNoNavigation.cfm">
		<p>&nbsp</p>


        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td valign="center" align="center"><table class="border" border="0" cellpadding="1" cellspacing="2" width="500">
                <tr>
                  <td><table border="0" cellpadding="0" cellspacing="1" width="100%">
                      <cfif IsDefined('invalid')>
                        <tr>
                          <td align="center" colspan="2"><div class="darkred">#trim(invalid)#</div></td>
                        </tr>
                      </cfif>

                      <tr>
                        <td class="default" align="right" width="160"><strong>Username:&nbsp;</strong></td>
                        <td width="340" align="left"><cfinput type="text" name="j_username" message="Error! Please Provide username" tooltip="Provide Your Username" required="yes" class="inputstyle" id="j_username" tabindex="1" size="25" maxlength="100" value = "D03097"></td>
                      </tr>
                      <tr>
                        <td class="default" align="right" width="160"><strong>Password:&nbsp;</strong></td>
                        <td width="340" align="left"><cfinput type="password" name="j_password" message="Error! Please Provide Password" tooltip="Password Required" required="yes" class="inputstyle" id="j_password" tabindex="2" size="25" maxlength="100" value = "6123324"></td>
                      </tr>
                       <tr>
                        <td align="center">&nbsp;</td>
                        <td align="left"><cfinput type="submit" name="submit" value="Login" class="tinyborder" tabindex="5">
                          </td>
                      </tr>
                  </table></td>
                </tr>
              </table></td>
          </tr>
        </table>
        </cfform>
      </cfoutput>

Open in new window

      
EMLLOGIN1.CFM
=============
<!--- Check for login here --->
<cflogin idletimeout="1800">
<cfif Not IsDefined('cflogin')>
  <cfinclude template="emlLogin.cfm">
  <cfabort>
  <cfelse>
  <cfif cflogin.name IS "" OR cflogin.password IS "">
    <cfset invalid  = "Error! Please Provide Username/Password">
    <cfinclude template="emlLogin.cfm">
    <cfabort>
    <cfelse>
    <cfinvoke component="myComponent" method="getUser" returnvariable="getChkrecords">
		<cfinvokeargument name="inUserId" value="#trim(cflogin.name)#">
		<cfinvokeargument name="inPassword" value="#trim(cflogin.password)#">
    </cfinvoke>
    <cfif getChkrecords.recordCount GT 0>
      <cfloginuser name="#cflogin.name#" Password = "#cflogin.password#" roles="#getChkrecords.lgRole#">
      <cfset session.loggedin = true>
      <cfset session.userid = #trim(cflogin.name)#>
      <cfelse>
      <cfset invalid = "Error! Invalid Username/Password">
      <cfinclude template="emlLogin.cfm">
      <cfabort>
    </cfif>
  </cfif>
</cfif>
</cflogin>	  

Open in new window

EMLLOGOUT.CFM
===========
<cfif StructKeyExists(form,"logout")>
	<cfset session.logout=true>
</cfif>

Open in new window

Errol FarroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dgrafxCommented:
The code you posted doesn't even contain "session.userid" except of one occurrence where you are setting it.
Please post code appropriate code.

NOTE: You need to start using Application.cfc instead of Application.cfm. Your onRequestStart is not going to be called automatically when in an Application.cfm like you have coded.
Do some research on how to get started with Application.cfc
0
Errol FarroAuthor Commented:
I am setting session.userid in emlLogin1.cfm.
If userid and password are valid, then I do <cfset session.userid = #trim(cflogin.name)#>

Btw, I changed the application.cfm to application.cfc and I am  still getting the same result.

Note: I forgot to add a line of code in EMLLOGOUT.CFM. Below please find the complete source for EMLLOGOUT.CFM


<cfif StructKeyExists(form,"logout")>
      <cfset session.logout=true>
</cfif>

cflocation url="emlVerification.cfm">


where emlVerification.cfm is the first screen a user should get after have successfully authenticated himself
0
dgrafxCommented:
i have to ask - did you read (fully and understand) what i said?

look - you said you were getting this error message: "Element USERID is undefined in SESSION."
that means that somewhere in your code you are referring to session.userid

other than where you set the value it does not exist anywhere in the code you posted!

what I actually said was this
>>The code you posted doesn't even contain "session.userid" except of one occurrence where you are setting it.<<
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Errol FarroAuthor Commented:
The program that throws the message "Element USERID is undefined in SESSION." is emlVerification.cfm

The logic is as follows
-http://..../emlVerification.cfm
-emlVerification.cfm calls emlConfirmation.cfm
-In emlConfirmation.cfm there is a logout button which calls emlLogout.cfm

Refer to the attached
0
Errol FarroAuthor Commented:
I am trying to attach the files emlVerification.cfm. Can you see it ?
emlVerification.txt
0
dgrafxCommented:
ok so now you include the file where the actual error occurs ...
anyway ...

the cause is because at the point the code (session.userid) is called - the variable no longer exists.
you can't call emlVerification unless you have session.userid set!
where a user logs out you can't then send them to a page that is asking for a session var - in this case session.userid
send them to login when they logout or send them to a home page or something ...
at the very least put this in your onRequestStart function:
<cfif Not StructKeyExists(session, "UserID")>
     <cfset session.UserID=0>
</cfif>
you can add other vars in there as well if needed
also when you go to a page where a user does need to be logged in then send them to login page

good luck
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Errol FarroAuthor Commented:
Many many thanks !!!!
0
dgrafxCommented:
glad you got it fixed ...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.