Link to home
Start Free TrialLog in
Avatar of gardine
gardine

asked on

SESSION variable does not exist

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?
Avatar of anandkp
anandkp
Flag of India image

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
Avatar of procept
procept

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
Avatar of gardine

ASKER

Thank you for the response.  Sorry for taking so long to relpy.  How do you enable the settings on the server (Windows 2000 Server)?
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
Avatar of gardine

ASKER

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?
Avatar of gardine

ASKER

Points increase.
Get in touch with ur sys admin & tell him abt this ... he shld be able to help u out !
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
Avatar of gardine

ASKER

Hello,

I am working with version 6, J2ee sessions are disabled, and the browsers are configured to support cookies.
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
Avatar of gardine

ASKER

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>
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
Avatar of gardine

ASKER

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>


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
Avatar of gardine

ASKER

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


Avatar of gardine

ASKER

are you saying it is blocked on the server side?
Avatar of gardine

ASKER

I tried your test and I am not getting prompted.
ASKER CERTIFIED SOLUTION
Avatar of procept
procept

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gardine

ASKER

That did it!...Thank-you VERY much.  I really appreciate your effort and perseverance.
You're welcome. Good thing we finally found a solution. :-))

Chris