Ask a Question related to Macromedia ColdFusion, Design and Development.
-
dspent #1
Session Problems....
I'm having a problem with my application at login...
What is happening is users are logging in successfully, performing their
actions and then logging out, via the logout link.... or some are just closing
the browser. In either case it shouldn't really matter as the session is set
to timeout after 20 minutes and most if not all of the users don't try to log
back in until hours later or the next day...
However, when they try to log back in they get to the index.cfm page where I
have a Welcome, USERNAME line and the get:
WELCOME,
Element NAME is undefined in SESSION.
The error occurred in D:\Inetpub\wwwroot\kbase\pub\index.cfm: line 58
56 : <cfoutput>
57 : <p>
58 : <b>Welcome, #Session.Name#!</b>
59 : </p>
60 :
--------------------------------------------------------------------------------
What I have to do to resolve the problem is provide them with the URL string
that performs the logout. Then they are able to log in successfully again.
It is as if the logout never occured BUT the session did expire....
How can I fix this? I have provided my application.cfm, ntsecurity.cfc and
index.cfm below. I need help ASAP as this and another app that uses the same
login method are slated to go live this week.
***APPLICATION.CFM***
<!--- Set a Start Time Variable for Page Processing Calculation --->
<cfset template_start = getTickCount()>
<!--- Set application defaults here --->
<cfapplication name="knowledge"
sessionmanagement="yes"
sessiontimeout="#CreateTimeSpan(0,0,20,0)#">
<!--- Define the Return Path URL via Cookie --->
<cfset cookie.return = #cgi.HTTP_REFERER#>
<!--- Define the Web Root Here --->
<cfset root = "http://kbase/">
<!--- Define the DOC and PDF file upload path on the webserver --->
<cfset UpPath = "d:\inetpub\wwwroot\kbase\upload">
<!--- Define Admin Email Here --->
<cfset KBAdmin = "">
<!--- Set the Domain to be authenticated against here --->
<cfset Request.myDomain="hnmc">
<!--- Check to see if logout link has been pressed and log the user out if so
--->
<cfif isdefined("url.logout")>
<CFLOGOUT>
<cfset StructDelete(Session, "Role")>
<cfset StructDelete(Session, "Name")>
<cfset StructClear(Session)>
<!--- redirect to home page --->
<meta http-equiv="Refresh" content="0;url=../index.cfm"></cfif>
<!--- If user is not logged in and authenticated force login with ntsecurity
CFC --->
<cflogin>
<cfif not IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<!---Perform login action using the NTSECURITY CFC --->
<cfset UserName = "#cflogin.name#">
<cfset Password = "#cflogin.password#">
<cfinvoke component = "NTSecurity" method = "authenticateUser"
returnVariable = "CheckUser" domain = "#Request.myDomain#"
userid = "#UserName#" passwd = "#Password#">
<!--- Check to see if user is authenticated by
NTSECURITY CFC --->
<cfif CheckUser Is "True">
<!--- Get the User's Name and Role from the Database --->
<cfquery name="qGetRole" datasource="kbank">
SELECT Role, FName, LName
FROM dbo.KBUsers
WHERE Userid = '#UserName#'
</cfquery>
<cfelse>
<cflocation addtoken="no" url="../invaliduser.cfm">
</cfif>
<!--- Login users with CFLOGINUSER method --->
<cfif qGetRole.RecordCount gt 0>
<cfoutput query="qGetRole">
<cfloginuser name = "#UserName#" password = "#Password#"
roles="#Role#">
<!--- Set some constant session
variables for the user --->
<cfset Session.Role = "#Trim(Role)#">
<cfset Session.Name = Trim(Fname) & " " & Trim(LName)>
</cfoutput>
<!--- If user is not authenticated or logged in for some reason, set
a loginmessage varibale and repeat --->
<cfelse>
<cfif qGetRole.RecordCount eq 0>
<cflocation addtoken="no" url="../invaliduser.cfm">
<cfelse>
<cfset loginmessage="Invalid Login">
<cfinclude template="loginform.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
***NTSECURITY.CFC***
<!---
This component implements methods for use for NT Authentication and
Authorization.
--->
<cfcomponent name="NTSecurity" >
<!--- Authenticates the user and outputs true on success and false on
failure. --->
<cffunction name="authenticateUser" access="REMOTE" output="no"
static="yes" hint="Authenticates the user." returntype="boolean">
<cfargument name="userid" type="string" required="true" />
<cfargument name="passwd" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
// authenticateUser throws an exception if it fails,
ntauth.authenticateUser(arguments.userid,
arguments.passwd);
</cfscript>
<cfreturn true>
<cfcatch>
<cfreturn false>
</cfcatch>
</cftry>
</cffunction>
<!---
Authenticates the user and outputs true on success and false
on failure.
--->
<cffunction access="remote" name="getUserGroups" output="false"
returntype="string" hint="Gets user groups." static="yes">
<cfargument name="userid" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
groups = ntauth.GetUserGroups(arguments.userid);
// note that groups is a java.util.list, which should
be
// equiv to a CF array, but it's not right now???
groups = trim(groups.toString());
groups = mid(groups,2,len(groups)-2);
</cfscript>
<cfreturn groups>
<cfcatch>
<cflog text="Error in ntsecurity.cfc method getUserGroups - Error:
#cfcatch.message#" type="Error" log="authentication" file="authentication"
thread="yes" date="yes" time="yes" application="no">
<cfreturn "">
</cfcatch>
</cftry>
</cffunction>
<!---
This method combines the functionality of authenticateUser and
getUserGroups.
--->
<cffunction access="remote" name="authenticateAndGetGroups"
output="false" returntype="string" hint="Authenticates the user and gets user
groups if it returns nothing the user is not authenticated" static="yes">
<cfargument name="userid" type="string" required="true" />
<cfargument name="passwd" type="string" required="true" />
<cfargument name="domain" type="string" required="true" />
<cftry>
<cfscript>
ntauth = createObject("java", "jrun.security.NTAuth");
ntauth.init(arguments.domain);
// authenticateUser throws an exception if it fails,
// so we don't have anything specific here
ntauth.authenticateUser(arguments.userid,
arguments.passwd);
groups = ntauth.GetUserGroups(arguments.userid);
// note that groups is a java.util.list, which should
be
// equiv to a CF array, but it's not right now
groups = trim(groups.toString());
groups = mid(groups,2,len(groups)-2);
</cfscript>
<cfreturn groups>
<cfcatch>
<cfreturn groups>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
***INDEX.CFM***
<!--- ColdFusion Coding Section --->
<cfparam name="Session.Role" default="Guest">
<!-- END OF COLDFUSION CODING -->
<!-- BEGIN HTML HEADER-META-TITLE SECTION -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- BEGIN SCRIPTING SECTION -->
<!-- END SCRIPTING SECTION -->
<!-- BEING STYLE SECTION -->
<link rel="stylesheet" type="text/css" href="site.css">
<style type="text/css">
<!--
.bodytext {
margin-top: 25px;
margin-left: 75px;
}
.noaccess {
margin-top: 50px;
margin-left: 300px;
font-family: verdana;
color: 5B461E;
font-weight: bold;
font-size: xx-small;
border: 1px dashed black;
background-color: EEE1B7;
width: 350px;
padding-left: 15px;
padding-top: 15px;
padding-bottom: 15px;
}
-->
</style>
<!-- END STYLE SECTION -->
<title>Information Services - Knowledgebase Application</title>
</head>
<!-- END META-HEAD-TITLE SECTION -->
<!-- HTML CODING AND COLDFUSION OUTPUT CODING BELOW -->
<body>
<div id="outer">
<!-- BEGIN HEADER ROW -->
<cfinclude template="indexheader.cfm">
<!-- END HEADER ROW -->
<!-- BEGIN BODY ROW -->
<d
dspent Guest
-
Session problems
Hi there... I've got a problem where a normal string variable loses its value after session_start() is called. The funny thing is, that this only... -
Session, SES, and SSL - Major session problems
I seem to be having the same type of problem... Can someone help me with this issue? basically - I just started using SSL secure pages on my site... -
[PHP] Session Problems with 4.3.2
No, basically I'm just trying to make sure sessions are working properly. I'm just setting a session variable (which works fine) and trying to... -
Session Problems with 4.3.2
I've been using up until a day or so ago version 4.0.6. I'm moving everything now to 4.3.2 but having problems with sessions. I've tried a basic... -
session problems in php 4.3.2
Hello, I have a problem with php 4.3.2. I have a php code and i used sessions, that code works properly in php 4.3.0 and now after upgrade php...



Reply With Quote

