Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 600169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:34:37+00:00 2026-05-13T16:34:37+00:00

I am testing out how to protect pages in coldfusion and have run into

  • 0

I am testing out how to protect pages in coldfusion and have run into an issue when attempting to create a process by which users can log out.

Essentially, I have three pages:

  1. Page A – The form that submits to
    Page B
  2. Page B – That checks the
    form.username and form.password
    against a database (works fine)
  3. Page
    C – Logout page (Which is where I am
    having an issue).

Page C throws a “variable Session is undefined” error

Here is the code on Page C:

<cfset StructClear(Session)>
<cflocation url="index.cfm">

Here is the code on Page B:

<cfif NOT IsDefined ("form.username")>
<cflocation url="index.cfm" addtoken="No">
</cfif>


<cfquery name="test" datasource="cfdb">
SELECT * FROM USERS
WHERE USERNAME = '#FORM.username#'
AND PASSWORD = '#FORM.password#'
</cfquery>


<!---<CFSET Session.LoggedIn = "1">
<CFSET Session.FirstName = "#test.FirstName#">--->

<CFIF test.RecordCount IS 0>
<cflocation url="index.cfm" addtoken="No">
<CFSET StructClear(Session)>
<cfelse>
<CFSET Session.LoggedIn = "1">
<!---<cflocation url="test.cfm" addtoken="No">--->
</cfif> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p><a href="logout.cfm">Log Out</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><br>
  This content is protected.
</p>
</body>
</html>

As you can see, nothing fancy 🙂

Now, I thought that the Session variable could be accessed by any page within a given browser instance, but I am obviously wrong.

What do I need to do for Page C (my logout page to be able to access the session variable).

Any guidance is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:34:38+00:00Added an answer on May 13, 2026 at 4:34 pm

    The Adobe docs reccommend against using structclear on the entire session, a better approach would be to make a sub element of the session named something like session.data and then structclear that. If you do want to make your code work try saving the key session internals then restoring them like this…

    <cflock timeout="15" throwontimeout="No" scope="SESSION" type="EXCLUSIVE">
       <cftry>
       <cfscript>
       variables.HoldCFID = session.CFID;
       variables.HoldCFT  = session.CFToken;
       variables.HoldSID  = session.SessionID;
       variables.HoldURLT = session.URLToken;
       structClear(session);
       session.CFID      = HoldCFID;
       session.CFToken   = HoldCFT;
       session.SessionID = HoldSID;
       session.URLToken  = HoldURLT;
       </cfscript>
      <cfcatch type="Any">
        <!--- {If the session strut was cleared without saving the vars first} --->
       <cfset rc = structClear(session)>
       Session Cleared in Catch<br>
      </cfcatch>
      </cftry>
    </cflock>
    

    Here is a good writeup with some background on stuctclearing the session structClear and Sessions – Still bad? from Ray Camden’s blog.

    Also your sample shows the classic attack vector for SQL injection, be sure to CFQueryParam your FORM.username and FORM.pasword 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII
I'm testing out the OpenERP 6.1 web client, and I sometimes have a sales
I'm testing out Eziriz .NET Reactor to protect a software, developed using Visual Studio
I was testing out an update to my app, and while logged into my
In testing out our API, one of our testers found out that when they
I'm testing out faults and exception handling on my service and am seeing odd
I was testing out RQ (Redis-Queue) when after running the command rqworker and testing
i'm just testing out the csv component in python, and i am having some
I am having issues testing out the Scala Parser Combinator functionality for a simple
I was testing out the db2 max function to see if it picks NULL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.