[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SESSION variable does not exist

Posted on 2003-10-31
21
Medium Priority
?
1,121 Views
Last Modified: 2013-12-24
Hello,

After placing my site on my ColdFusion server I am getting the following message: "SESSION variable does not exist".  I do not get it when accessing the site locally on my development server.  Any ideas why?
0
Comment
Question by:gardine
  • 10
  • 9
  • 2
21 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 9662226
Hi check these :

1. Is ur server allowing sessions [server settings / proxy ...]
2. I hope u have the sessions enabled on ur CFSERVER Admin & CFApplication TAG.
3. Does the browser u are using - has sessions enabled ?

Once u have confirmed the above 3 - u shld be able to get ur thigns to work properly !

K'Rgds
Anand
0
 
LVL 4

Expert Comment

by:procept
ID: 9662447
Hi,

I second Anand's points 1 and 2. Also make sure that you have set the session var before you try to retrieve it.

Anand: What do you mean by "browser has sessions enabled"? Cookies? You can it can be done without cookies. ;-)

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9671189
Thank you for the response.  Sorry for taking so long to relpy.  How do you enable the settings on the server (Windows 2000 Server)?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 4

Expert Comment

by:procept
ID: 9671236
In CF-Admin go to "Server Settings - Memory Variables".

Check "Enable Session Variables" and click "Submit changes"

In Application.cfm use
<cfapplication name="myApp" sessionmanagement="yes">

HTH,

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9674390
Thank-You procept,

All the above said settings are in place, but I am still getting the error.  In my previous comment I was wondering if any settings had to be made on the actual server itself....not CF.  Any idea what may still be the problem?
0
 
LVL 1

Author Comment

by:gardine
ID: 9674398
Points increase.
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9676255
Get in touch with ur sys admin & tell him abt this ... he shld be able to help u out !
0
 
LVL 4

Expert Comment

by:procept
ID: 9676816
Hi,

- what cf version are you working with?
- are J2ee Sessions enabled or disabled? (Again under "Server Settings - Memory Variables)
- does your browser support cookies?


Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9678855
Hello,

I am working with version 6, J2ee sessions are disabled, and the browsers are configured to support cookies.
0
 
LVL 4

Expert Comment

by:procept
ID: 9684961
can you show us the code that throws the error. Also, let us know how the user is directed to the page where the error occurs.

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9697201
Hi,

Once again, sorry for the delayed response.  Here is my code (messy, I know)

FIRST LOGIN FILE:

<html>
<head>
<title></title>
<script language="javascript" src="../scroller/ts_files/scroll.js"></script>
</head>
<body>
<table width="708" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2" cellpadding="0" cellspacing="0" valign="bottom" height="84" width="720"><img border="0" src="../univer_graph/logo.gif" style="float: left" width="456" height="80">
      <table border="1" width="244" cellpadding="0" cellspacing="0" align="left" bgcolor="#336699">
            <tr><td bgcolor="#ffffff" width="235" height="72" valign="middle" align="center">
            <p align="left"><SCRIPT LANGUAGE="JavaScript">Tscroll_init (0)</SCRIPT></td></tr>
      </table>
      <p>&nbsp;
      
      </p>
      </td>
    </tr>
  </table>
<table border="1" bordercolor="#669999" width="708"  height="280" cellpadding="0" cellspacing="0">
<tr>
<td height="278"><div align="center">
<cfif IsDefined("URL.Message")>
      <cfoutput><font face="Trebuchet MS"><strong>#URL.Message#</strong></font></cfoutput>
</cfif>
<cfform action="login2.cfm" method="post">
      <p><font color="#333366" face="Arial, Helvetica, sans-serif"><strong><br>
            <font size="4">Welcome! Please login to continue:</font></strong></font></p>
      <table width="538" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="269"><p align="right"><b><font face="Trebuchet MS">User Name:</font></b></p>
            <p align="right"><b><font face="Trebuchet MS">Password:</font></b></p></td>
          <td width="269"><p align="left">
            <cfinput type="Text" required="Yes" message="Please Enter a User Name" name="userid" maxlength="8" size="6.75">
        </p>
            <p align="left">
              <cfinput type="Password" required="Yes" message="Please Enter a Password" name="password" maxlength="8" size="8">
              </td>
          </tr>
        </table>
      <p>
  <font face="Trebuchet MS">
  <input type="submit" value="Login">
  </font>
      </cfform>
</div></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

SECOND LOGIN FILE:

<cfquery name="GetUser" datasource="bcuintra">
SELECT      *
FROM       users
WHERE      userid       = '#Form.userid#'
AND       psswd       = '#Form.Password#'
</cfquery>

<cfif GetUser.RecordCount gt 0>
      <cfset Session.userid = GetUser.userid>
      <cfcookie name="userid" value="GetUser.userid" expires="never">

      <cfquery Datasource="bcuintra" name="UpdateUser">
            UPDATE       users
            SET       pastlogin=lastlogin, lastlogin = #CreateODBCDateTime(Now())#
            WHERE       userid = '#session.userid#'
      </cfquery>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      <title>Your Account</title>
</head>

<body>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://BTF01as08/BCUIntra/home/home.cfm">
</body>
</html>
<cfelse>
<cfset Session.loggedin = True>
<cfset loginpage = "login.cfm?loginmode=reg&Message=" & URLEncodedFormat("Invalid User Name/Password Combination")>
<cfset loginpage = loginpage & "&username=" & URLEncodedFormat(#Form.userid#)>
<cflocation url="#loginpage#">
</cfif>

APPLICATION FILE:

<cfapplication name="loginApp" sessionmanagement="Yes" clientmanagement="yes" sessiontimeout="20">
<cfparam name="Session.userid" default="">
<cfparam name="Session.psswd" default="">

CHECK AUTHORITY FILE:

<cfset bLoggedIn = False>
<cfif IsDefined("Session.userid")>
      <cfif Session.userid neq "">
            <!--- if it is not false, we can assume that we have stored the session.username --->
            <!--- so we set logged in to True - meaning the user is verified --->
            <cfset bLoggedIn = True>      
      </cfif>
<cfelse>
      <cfif IsDefined("Cookie.username")>
            <cfif Cookie.userid neq "">
                  <cfset Session.userid = Cookie.userid>
                  <cfset bLoggedIn = True>
            </cfif>
      </cfif>
</cfif>
<cfif bLoggedIn eq False>
      <cfinclude template="myErrorFile.cfm">
      <cfexit>
</cfif>
0
 
LVL 4

Expert Comment

by:procept
ID: 9699833
Hi,

on which page do you get the error? Is it a CF error or is it "just" that CF doesn't recognize the valid login?

There is an issue with session vars and cfloccation on the same page, but, before you try to change the code, we should try to find an easy solution... :-))

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9701390
Here is the error I am geting:

Error Accessing this page - you need to login prior to accessing restricted content.


Error Occurred While Processing Request  
Element USERID is undefined in SESSION.  
 
 
The Error Occurred in C:\Inetpub\wwwroot\BCUIntra\home\home.cfm: line 6
 
4 :       SELECT       firstname, lastname,  pastlogin
5 :       FROM       users
6 :       WHERE      userid = '#Session.userid#'
7 : </cfquery>
8 : <cfquery name="top10" datasource="bcuintra">


...and here is a snippet of code from home.cfm...

<cfinclude template="../login/include_CheckAuthority.cfm">

<cfquery name="user_inf" datasource="bcuintra">
      SELECT       firstname, lastname,  pastlogin
      FROM       users
      WHERE      userid = '#Session.userid#'
</cfquery>
<cfquery name="top10" datasource="bcuintra">
      SELECT  TOP 10 *
      FROM traffic
      WHERE userid = '#Session.userid#'
      ORDER BY multihits DESC
</cfquery>


0
 
LVL 4

Expert Comment

by:procept
ID: 9701638
hmmm... you said this occurs only on production server, not with local dev server.... does your browser use a proxy??? Sometimes proxies won't admit cookies to go to the client, that would explain why you loose the session.

Another question would be if you have multiple Application.cfm's in your application?

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9701792
Yes...my browser is set to use proxies but it is also set to bypass proxies if the address is local.  Also, I only have one application.cfm
0
 
LVL 4

Expert Comment

by:procept
ID: 9701842
well, I guess that the proxy does not allow the cookies to go through.... have your browser notify you for each cookie, if you get no msg. for cfid and cftoken, then they are filtered out.

I searched macromedia.com and found this article on session var problems (should actually be resolved with MX; but, I might be wrong here ;-)): http://www.macromedia.com/support/coldfusion/ts/documents/tn18171.htm

HTH,

Chris


0
 
LVL 1

Author Comment

by:gardine
ID: 9701961
are you saying it is blocked on the server side?
0
 
LVL 1

Author Comment

by:gardine
ID: 9701972
I tried your test and I am not getting prompted.
0
 
LVL 4

Accepted Solution

by:
procept earned 400 total points
ID: 9706447
> I tried your test and I am not getting prompted.

so if you are not getting any cookies, my best bet is that they are lost somewhere on the way. Could be a proxy or a firewall that won't let the cookies go through. Some proxies do that...

Try to set up at least part of the app without cookies. Use <cfapplication setclientcookies="no"> in Application.cfm and change links and cflocations and meta redeirects, etc, to use URLSessionFormat() (new function in MX):

<a href="#URLSesionFormat('myPage.cfm?param1=value1')">   or
<cflocation URL="#URLSessionFormat('#myPageVar#')#" addtoken="no">

I would suggest doing it for the login part only for a start... if it works, you still can change the rest of the app.

BTW, if you have a good editor like Homesite+ or CFStudio, you can do the changes in a few seconds with "Extended Search and Replace".

HTH,

Chris
0
 
LVL 1

Author Comment

by:gardine
ID: 9712391
That did it!...Thank-you VERY much.  I really appreciate your effort and perseverance.
0
 
LVL 4

Expert Comment

by:procept
ID: 9713294
You're welcome. Good thing we finally found a solution. :-))

Chris
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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