Skip to main content
June 16, 2009
Question

Session variable assingment issue

  • June 16, 2009
  • 1 reply
  • 1060 views

I am having issues with Session variables since I am not able to set a session variable. My company Intranet page checks for a session variable and then allows users to login. Please if any one can help me with code or guide what I am doing wrong.

I have tried updating session variable in application.cfm but so far no luck..

 

Auth.cfm

<cfapplication name="LID"

               ClientManagement="No"

               SessionManagement="Yes"

               SessionTimeout="#CreateTimeSpan(0,0,30,0)#"

               SetClientCookies="No">

<cflock scope="session" timeout="30" type="ReadOnly">

        <cfset Session.LID="#cflogin.name#">

     

        </cflock>

                        <cfset Session.USERID= "Request.ses.LID"> ( Session.USERID is set to check user and allow their access)

This topic has been closed for replies.

1 reply

Inspiring
June 16, 2009

application.cfm code runs before any code on any page.  In your case, this

<cfset Session.LID="#cflogin.name#">

will run before the user logs in.

June 17, 2009

Hello Dan,

Thanks for a reply and what approach should I choose so that once user logs in , session.USERID=cflogin.username.

I would really appreciate your help.

Inspiring
June 17, 2009

I've only had to do it once, and the code is below.  An improvement would be to change this sort of thing

<cfelse>  <!--- not logged in --->
<cfinclude template="loginform.cfm">
<cfabort>

to this sort of thing.

<cfelse>  <!--- not logged in --->
<cflocation url="loginform.cfm">

<cflogin>
<cfif isDefined( "cflogin" ) and not cgi.SCRIPT_NAME contains "logout">

<cfquery name="authenticate" datasource="#session.dsn#">
select userid, roles
from users
where userid = '#cflogin.name#'
and password = '#hash(cflogin.password)#'
</cfquery>

<cfif authenticate.recordcount>  <!--- successful log in --->

<cfcookie expires="never" name="cashflowlogin" value="#authenticate.userid#">

<cfloginuser
name="#cflogin.name#"
password="#cflogin.password#"
roles="#authenticate.roles#"/>

<cfelse> <!--- unsuccessful log in --->

<cfset LogInMessage = "<h3>Invalid Login, Please Try Again<h3>"> 
<cfinclude template="loginform.cfm">
<cfabort>

</cfif>  <!--- successful log in --->

<cfelse>  <!--- not logged in --->
<cfinclude template="loginform.cfm">
<cfabort>

</cfif>  <!--- is defined cflogin --->

</cflogin>