Solved

SESSION variable does not exist

Posted on 2003-10-31
21
1,102 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 100 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Build and evolve an interactive experience 1 85
Configure IIS to process JSON 10 63
Problem to Popup 37 81
Summernote required 3 58
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now